是否有可能通過使用jQuery禁用某個鍵盤按鍵(如星號或字符串)?jquery禁用鍵盤按鍵
8
A
回答
11
您不能禁用擊鍵這樣,但你可以用jQuery捕獲並覆蓋其行爲(返回false)。下面的示例捕獲輸入密鑰。只需將13更改爲您需要禁用的任何鍵碼。
$("input").keypress(function (evt) {
var keycode = evt.charCode || evt.keyCode;
if (keycode == 13) { //Enter key's keycode
return false;
}
});
1
處理onKeyDown
,然後preventDefault
就可以了。
0
只需添加一個OnKeyUp,Down-EventListener
到你的HTML頁面,如果按下的鍵是要忽略你剛纔preventDefault
0
您可以使用下面的插件是這樣的: $('#text_input').filter_input({regex:'[a-z]'})
;
http://www.thimbleopensource.com/tutorials-snippets/jquery-plugin-filter-text-input
1
我能想到的是這樣的:通過返回false你告訴瀏覽器不允許按下的鍵事件
6
我不得不關閉所有的鑰匙,但
// Bind this keypress function to the html (not sure about this) or body tags of your page
$("body").keypress(function (evt) {
//Determine where the character code is coming from
var charCode = evt.charCode || evt.keyCode;
if (charCode == 13) { //Enter key's keycode, could be any other key
return false;
}
});
F11和ESC。所以我這樣做了。認爲這可能有助於某人。 :)
$(document).on('keydown',function(e)
{
var key = e.charCode || e.keyCode;
if(key == 122 || key == 27)
{}
else
e.preventDefault();
});
+0
其有用的,但它不工作在PrtSc屏幕,actully我想用這個沒有人可以保存我的網頁,甚至沒有截圖,如果你可以plz幫助 – sunil 2016-11-11 08:06:01
相關問題
- 1. 禁用android鍵盤按鈕
- 2. 禁用iphone鍵盤按鈕
- 3. 如何禁用所有鍵盤按鍵?
- 4. Android禁用鍵盤按鍵反饋
- 5. 全屏禁用所有鍵盤按鍵
- 6. VBA PowerPoint - 禁用鍵盤按鍵?
- 7. 禁用鍵盤jQuery的
- 8. 如何使用javascript或jquery禁用全鍵盤按鍵?
- 9. jQuery禁用鍵盤上的提交按鍵
- 10. Android鍵盤。禁用鍵
- 11. 禁用鍵盤快捷鍵
- 12. 禁用鍵盤快捷鍵
- 13. 禁用鍵盤上的鍵
- 14. 用Jquery模擬鍵盤按鍵
- 15. 禁用鍵盤上的國際鍵盤選擇按鈕
- 16. 禁用Android鍵盤
- 17. 當禁用鍵盤
- 18. 禁用Android鍵盤
- 19. 禁用軟鍵盤
- 20. 如何禁用鍵盤上的「按住」按鍵
- 21. 顯示鍵盤時禁用按鈕
- 22. 通過鍵盤禁用主頁按鈕
- 23. 結合按鍵和鍵盤 - jQuery
- 24. 停止影響jQuery的鍵盤按鍵
- 25. 使用Application.OnKey禁用鍵盤鍵
- 26. 使用shadowbox禁用鍵盤快捷鍵?
- 27. 使用Java禁用某些PC鍵盤按鍵
- 28. 禁用外部鍵盤的鍵盤快捷鍵
- 29. 在android軟鍵盤中禁用/檢測鍵盤解鎖鍵
- 30. 禁用鍵盤快捷鍵(是:從鍵盤離開焦點)
剛剛意識到會捕獲輸入字段。如果你想禁用整個頁面,將「input」改爲「body」。 – detheridge02 2012-01-10 14:54:18