A small demo that uses js to capture which key is pressed on the keyboard, and then displays the corresponding code value
<!DOCTYPE html> <html> <head> <script> function showKeyCode(event) { document.getElementById("result").value= event.keyCode; } </script> </head> <body onkeyup="showKeyCode(event)"> <p>按下键盘上的键,文本框中会显示对应的code</p> <input type="text" id="result" value="1" /> </body> </html>
The above is the entire content of this article, I hope you all like it.