博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
页面滚动条&按键执行事件
阅读量:5216 次
发布时间:2019-06-14

本文共 5261 字,大约阅读时间需要 17 分钟。

判断页面滚动条

$(window).bind('scroll', function () {            //算出鼠标移动到顶部的高度。            var scrollt = document.documentElement.scrollTop + document.body.scrollTop;            if (scrollt > 600) {                $(".return").fadeIn(500);                //进行操作。            } else {                $(".return").fadeOut(500);            }        })

判断按键

document.onkeydown = function (event) {var e=event||window.event||arguments.callee.caller.arguments[0];        if (e && e.keyCode == 13) {               } }

 

1 js 里面的键盘事件经常用到,所以收集了键盘事件对应的键码来分享下:   2 keyCode 8 = BackSpace BackSpace  3 keyCode 9 = Tab Tab  4 keyCode 12 = Clear  5 keyCode 13 = Enter  6 keyCode 16 = Shift_L  7 keyCode 17 = Control_L  8 keyCode 18 = Alt_L  9 keyCode 19 = Pause 10 keyCode 20 = Caps_Lock 11 keyCode 27 = Escape Escape 12 keyCode 32 = space 13 keyCode 33 = Prior 14 keyCode 34 = Next 15 keyCode 35 = End 16 keyCode 36 = Home 17 keyCode 37 = Left 18 keyCode 38 = Up 19 keyCode 39 = Right 20 keyCode 40 = Down 21 keyCode 41 = Select 22 keyCode 42 = Print 23 keyCode 43 = Execute 24 keyCode 45 = Insert 25 keyCode 46 = Delete 26 keyCode 47 = Help 27 keyCode 48 = 0 equal braceright 28 keyCode 49 = 1 exclam onesuperior 29 keyCode 50 = 2 quotedbl twosuperior 30 keyCode 51 = 3 section threesuperior 31 keyCode 52 = 4 dollar 32 keyCode 53 = 5 percent 33 keyCode 54 = 6 ampersand 34 keyCode 55 = 7 slash braceleft 35 keyCode 56 = 8 parenleft bracketleft 36 keyCode 57 = 9 parenright bracketright 37 keyCode 65 = a A 38 keyCode 66 = b B 39 keyCode 67 = c C 40 keyCode 68 = d D 41 keyCode 69 = e E EuroSign 42 keyCode 70 = f F 43 keyCode 71 = g G 44 keyCode 72 = h H 45 keyCode 73 = i I 46 keyCode 74 = j J 47 keyCode 75 = k K 48 keyCode 76 = l L 49 keyCode 77 = m M mu 50 keyCode 78 = n N 51 keyCode 79 = o O 52 keyCode 80 = p P 53 keyCode 81 = q Q at 54 keyCode 82 = r R 55 keyCode 83 = s S 56 keyCode 84 = t T 57 keyCode 85 = u U 58 keyCode 86 = v V 59 keyCode 87 = w W 60 keyCode 88 = x X 61 keyCode 89 = y Y 62 keyCode 90 = z Z 63 keyCode 96 = KP_0 KP_0 64 keyCode 97 = KP_1 KP_1 65 keyCode 98 = KP_2 KP_2 66 keyCode 99 = KP_3 KP_3 67 keyCode 100 = KP_4 KP_4 68 keyCode 101 = KP_5 KP_5 69 keyCode 102 = KP_6 KP_6 70 keyCode 103 = KP_7 KP_7 71 keyCode 104 = KP_8 KP_8 72 keyCode 105 = KP_9 KP_9 73 keyCode 106 = KP_Multiply KP_Multiply 74 keyCode 107 = KP_Add KP_Add 75 keyCode 108 = KP_Separator KP_Separator 76 keyCode 109 = KP_Subtract KP_Subtract 77 keyCode 110 = KP_Decimal KP_Decimal 78 keyCode 111 = KP_Divide KP_Divide 79 keyCode 112 = F1 80 keyCode 113 = F2 81 keyCode 114 = F3 82 keyCode 115 = F4 83 keyCode 116 = F5 84 keyCode 117 = F6 85 keyCode 118 = F7 86 keyCode 119 = F8 87 keyCode 120 = F9 88 keyCode 121 = F10 89 keyCode 122 = F11 90 keyCode 123 = F12 91 keyCode 124 = F13 92 keyCode 125 = F14 93 keyCode 126 = F15 94 keyCode 127 = F16 95 keyCode 128 = F17 96 keyCode 129 = F18 97 keyCode 130 = F19 98 keyCode 131 = F20 99 keyCode 132 = F21100 keyCode 133 = F22101 keyCode 134 = F23102 keyCode 135 = F24103 keyCode 136 = Num_Lock104 keyCode 137 = Scroll_Lock105 keyCode 187 = acute grave106 keyCode 188 = comma semicolon107 keyCode 189 = minus underscore108 keyCode 190 = period colon109 keyCode 192 = numbersign apostrophe110 keyCode 210 = plusminus hyphen macron111 keyCode 211 =112 keyCode 212 = copyright registered113 keyCode 213 = guillemotleft guillemotright114 keyCode 214 = masculine ordfeminine115 keyCode 215 = ae AE116 keyCode 216 = cent yen117 keyCode 217 = questiondown exclamdown118 keyCode 218 = onequarter onehalf threequarters119 keyCode 220 = less greater bar120 keyCode 221 = plus asterisk asciitilde121 keyCode 227 = multiply division122 keyCode 228 = acircumflex Acircumflex123 keyCode 229 = ecircumflex Ecircumflex124 keyCode 230 = icircumflex Icircumflex125 keyCode 231 = ocircumflex Ocircumflex126 keyCode 232 = ucircumflex Ucircumflex127 keyCode 233 = ntilde Ntilde128 keyCode 234 = yacute Yacute129 keyCode 235 = oslash Ooblique130 keyCode 236 = aring Aring131 keyCode 237 = ccedilla Ccedilla132 keyCode 238 = thorn THORN133 keyCode 239 = eth ETH134 keyCode 240 = diaeresis cedilla currency135 keyCode 241 = agrave Agrave atilde Atilde136 keyCode 242 = egrave Egrave137 keyCode 243 = igrave Igrave138 keyCode 244 = ograve Ograve otilde Otilde139 keyCode 245 = ugrave Ugrave140 keyCode 246 = adiaeresis Adiaeresis141 keyCode 247 = ediaeresis Ediaeresis142 keyCode 248 = idiaeresis Idiaeresis143 keyCode 249 = odiaeresis Odiaeresis144 keyCode 250 = udiaeresis Udiaeresis145 keyCode 251 = ssharp question backslash146 keyCode 252 = asciicircum degree147 keyCode 253 = 3 sterling148 keyCode 254 = Mode_switch149 使用event对象的keyCode属性判断输入的键值150 eg:if(event.keyCode==13)alert(“enter!”);151 键值对应表152 A  0X65  U   0X85153 B  0X66  V   0X86154 C  0X67  W   0X87155 D  0X68  X   0X88156 E  0X69  Y   0X89157 F  0X70  Z   0X90158 G  0X71  0   0X48159 H  0X72  1   0X49160 I  0X73  2   0X50161 J  0X74  3   0X51162 K  0X75  4   0X52163 L  0X76  5   0X53164 M  0X77  6   0X54165 N  0X78  7   0X55166 O  0X79  8   0X56167 P  0X80  9   0X57168 Q  0X81 ESC  0X1B169 R  0X82 CTRL  0X11170 S  0X83 SHIFT 0X10171 T  0X84 ENTER 0XD172 如果要使用组合键,则可以判断是否同时按下了这几个键,比如ctrl键、shift键以及alt键的组合使用就可以判断是否多按下了ctrl键、shift键以及alt键

转载于:https://www.cnblogs.com/zJuevers/p/8478137.html

你可能感兴趣的文章
[LeetCode]662. Maximum Width of Binary Tree判断树的宽度
查看>>
WinForm聊天室
查看>>
【Python学习笔记】1.基础知识
查看>>
梦断代码阅读笔记02
查看>>
Java 线程安全问题
查看>>
selenium学习中遇到的问题
查看>>
大数据学习之一——了解简单概念
查看>>
Linux升级内核教程(CentOS7)
查看>>
Lintcode: Partition Array
查看>>
分享适合个人站长的5类型网站
查看>>
类别的三个作用
查看>>
【SICP练习】85 练习2.57
查看>>
runC爆严重安全漏洞,主机可被攻击!使用容器的快打补丁
查看>>
Maximum Product Subarray
查看>>
solr相关配置翻译
查看>>
通过beego快速创建一个Restful风格API项目及API文档自动化(转)
查看>>
解决DataSnap支持的Tcp长连接数受限的两种方法
查看>>
Synchronous/Asynchronous:任务的同步异步,以及asynchronous callback异步回调
查看>>
ASP.NET MVC5 高级编程-学习日记-第二章 控制器
查看>>
Hibernate中inverse="true"的理解
查看>>