2
我正在編寫與JavaScript捕獲鍵盤輸入的東西,但問題是,每當用戶按下一個鍵時出現錯誤聲音。我該如何禁用它?鍵盤錯誤聲音捕捉KeyCode時
我正在編寫與JavaScript捕獲鍵盤輸入的東西,但問題是,每當用戶按下一個鍵時出現錯誤聲音。我該如何禁用它?鍵盤錯誤聲音捕捉KeyCode時
@ Polaris878
function KeyPressed(e)
{
if (!e) e = window.event;
if (e.which)
{
keycode = e.which
}
else if (e.keyCode)
{
keycode = e.keyCode
}
switch (keycode)
{
case 49:
key = "1";
break;
case 50:
key = "2";
break;
case 51:
key = "3";
break;
case 52:
key = "4";
break;
case 53:
key = "5";
break;
case 54:
key = "6";
break;
case 55:
key = "7";
break;
case 56:
key = "8";
break;
case 57:
key = "9";
break;
case 48:
key = "0";
break;
default:
key = "";
return false;
break
}
if (keys == "NULL")
{
keys = key
}
else
{
keys = keys + key
} if (keys.length >= 5)
{
document.formular.submit();
}
document.formular.code.value = keys;
}
var keys = "";
document.onkeydown = KeyPressed
你介意我們展示你的JavaScript代碼,捕獲你的按鍵/關閉事件? – Polaris878
@ Polaris878在這裏你去↓ – glenmyles