【文件属性】:
文件名称:isKeyPressed:一种轻量级(398字节)的方法,用于检查用户是否在浏览器中按下了键
文件大小:3KB
文件格式:ZIP
更新时间:2021-05-08 21:10:08
JavaScript
isKeyPressed
一种轻巧的方式(398字节),用于检查用户是否在浏览器中按下了键。
忘记使用无聊的事件侦听器。 调用单个函数KeyPressing.isKeyPressed() ,您可以知道用户是否正在按下特定的键。
if ( KeyPressing . isKeyPressed ( 13 ) ) { //Pass the keyCode integer as parameter
console . log ( 'The Enter key is being pressed!' )
} else {
console . log ( 'The Enter key is NOT being pressed!' )
}
设置
将文件isKeyPressed.min.js包含到您的项目中,并将其添加为资源脚本:
< script src =" pa
【文件预览】:
isKeyPressed-main
----README.md(2KB)
----LICENSE(1KB)
----isKeyPressed.js(838B)
----isKeyPressed.min.js(402B)