keyCode

JavaScript keyCode

JS用來識別特定鍵的鍵盤碼

鍵盤碼査詢

方法一:網頁査詢

Keycode

方法二:console.log

window.addEventListener("keydown",
 function(e){
 console.log(e.keyCode);
 }
);

//然後打開console,對著網頁區域任意按鍵盤,就會出現鍵盤碼

相同方法:event.which

window.addEventListener("keydown",
 function(e){
 console.log(e.which);
 }
);

//一樣打開console,對著網頁區域任意按鍵盤,就會出現鍵盤碼

Leave a Reply

Your email address will not be published. Required fields are marked *