我的網頁需要一些熱鍵,只需一個熱鍵。所以我需要找出用戶是否正在輸入或不應用熱鍵。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不是租戶是否正確?