Home > Web Front-end > JS Tutorial > body text

Javascript implements capturing keys pressed on the keyboard_javascript skills

WBOY
Release: 2016-05-16 16:01:07
Original
1145 people have browsed it

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>
Copy after login

The above is the entire content of this article, I hope you all like it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template