Javascript:键盘捕获
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Javascript:键盘捕获相关的知识,希望对你有一定的参考价值。
Usage:
var isOpera = (navigator.userAgent.indexOf('Opera') != -1); var isIE = (!isOpera && navigator.userAgent.indexOf('MSIE') != -1); var keyPressed = 0; if(!isIE){ document.captureEvents(Event.KEYPRESS); } function captureKeyboard(e) { e=e?e:event; document.title = event.keyCode + ' - ' + e.keyCode; if (isIE) { keyPressed = e.keyCode; }else{ keyPressed = e.charCode; } window.status = keyPressed; return true; }
以上是关于Javascript:键盘捕获的主要内容,如果未能解决你的问题,请参考以下文章