<!DOCTYPE html>
<html>
<body>
<p>当用户在输入字段中按下一个键时会触发函数。</p>
<input type="text" onkeypress="myFunction()">
<script>
function myFunction() {
alert("You pressed a key inside the input field");
}
</script>
</body>
</html>