使用JavaScript和jQuery处理按键事件(F1-F12),跨浏览器 [英] Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser
问题描述
我不知道有什么陷阱要避免,我目前还不能测试在任何其他浏览器的实现比Internet Explorer 8,谷歌浏览器和Mozilla FireFox 3。
任何建议,一个完整的跨浏览器解决方案?像一个经过良好测试的jQuery库或者可能只是vanilla jQuery / JavaScript?
问题是这个网页: http://www.quirksmode.org/js/keys.html
他们说的是关键代码在Safari上是奇怪的,并且在其他地方一致(除了IE上没有按键事件,但我相信keydown的作用)。
I want to handle F1-F12 keys using JavaScript and jQuery.
I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Explorer 8, Google Chrome and Mozilla FireFox 3.
Any suggestions to a full cross-browser solution? Something like a well-tested jQuery library or maybe just vanilla jQuery/JavaScript?
The best source I have for this kind of question is this page: http://www.quirksmode.org/js/keys.html
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).
这篇关于使用JavaScript和jQuery处理按键事件(F1-F12),跨浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!