<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
alert("您在输入字段中按了一个键");
}
</script>
</head>
<body>
<p>当用户在输入字段中按键时,将触发函数。</p>
<input type="text" onkeydown="myFunction()">
</body>
</html>