當我在我的textarea中按任意鍵時,它看起來像e.keycode不能正常工作。但是當我按下我的textarea中的任何鍵時,它總是會觸發。請幫忙嗎?爲什麼e.keyCode在我的textarea中沒有收到「{」?
function d(e) {
var key = (e.keyCode);
if (key == 229) {
alert("hello");
return false;
}
}
<textarea id="msg" onkeyup="d(event)">
</textarea>
我不工作在PC上。我在Android瀏覽器上測試這個。
https://stackoverflow.com/questions/4471582/javascript-keycode-vs-which – tom10271
@EvgenyKolyakov:不,它是'e.which',但鑑於OP引用的症狀,這並不是說他們使用了錯誤的屬性(但不清楚*是什麼錯誤)。 –
你忘記了} –