我的网页需要一些热键,只需一个热键。所以我需要找出用户是否正在输入或不应用热键。jquery确定用户是否正在输入
1
A
回答
2
您可以在文档的身体使用keypress事件
$(document.body).keypress(function(event){
//do your stuff (event.keyCode tells you what's been pressed)
});
1
你是说像this? (当你按下TAB键和重点是页面上的任何地方它的警报)
$(document).keypress(function(event) {
if (event.keyCode == 9) //TAB key
{
alert('this is the tab key!');
}
});
1
jQuery(function($){
$(window).keypress(function(e){ //alternatively look up the keydown and keyup functions
switch (e.which)
{
case 13: //whatever key code you want to check for
{
//do stuff
} return false; //prevent propagation of keypress event
default:
{
//log the keycode to console so you can figure out which key is which
//there are a number of tables of keycodes available online.
if (window.console) console.log(e.which);
} break;
}
});
});
请不要破坏你的用户体验:使用你的权力是好是真棒。
相关问题
- 1. 询问用户输入是否正确y/n在C
- 2. 如何检查用户输入路径是否正确?
- 3. 用户输入,验证日期格式是否正确
- 4. JAVA-无法检查用户输入日期是否正确
- 5. 检查是否有正确的用户输入
- 6. 功能来检查用户的输入是否正确无效
- 7. 无法从服务器验证用户输入是否正确?
- 8. 如何检查用户是否正确输入命令 - C#
- 9. 确定用户输入是回文
- 10. magento确定用户是否输入了送货信息
- 11. Java:确定用户是否已停止输入
- 12. 检查输入密码是否正确
- 13. 如果我在URL中输入用户名,是否存在正确的方法?
- 14. 检查输入是否正确/不正确,并为输入区域着色
- 15. 确定输入是否为域
- 16. 如何确保用户输入的格式是正确的python
- 17. 知道输入是否正在使用并禁用热键(jquery)
- 18. 正确处理用户输入
- 19. 编写JQuery是否正确
- 20. 确定XMPP用户是否在线
- 21. 不确定strpos()是否正确使用
- 22. 在R中的用户定义函数中,我如何检查输入在R中的格式是否正确?
- 23. 确定行是否在或不是jquery
- 24. 提示用户输入正确的输入 - tic tac toe游戏
- 25. 根据用户输入确定颜色
- 26. 什么是验证用户输入的正确方法?
- 27. 在Perl中,如何确定是否存在标准输入?
- 28. 使用switch语句来确定用户输入是什么
- 29. 检查输入是否是正确的整数
- 30. AVAudioPlayer不是租户是否正确?