且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 JavaScript 和 jQuery,跨浏览器处理按键事件 (F1-F12)

更新时间:2022-11-18 12:18:49

这类问题的***来源是这个页面:http://www.quirksmode.org/js/keys.html

The best source I have for this kind of question is this page: http://www.quirksmode.org/js/keys.html

他们说的是 Safari 上的键码很奇怪,其他地方都一致(除了 IE 上没有按键事件,但我相信 keydown 有效).

What they say is that the key codes are odd on Safari, and consistent everywhere else (except that there's no keypress event on IE, but I believe keydown works).