javascript键盘事件

2025年05月07日 09:08
有3个网友回答
网友(1):

首先


这句的 onKeyPress 多余了,因为上面的 JS 代码已经给他绑定。
其次,因为这个

不可编辑,所以不会产生 keypress 事件。

给你改一下程序,监听 window 的 keypress,显示在指定区域。



JavaScript测试



Displaying Typed Characters


This document includes a simple script that displays the keys you type in the paragraph below. Type a few keys and try it.





网友(2):

小小的改动了下。onKeyPress只支持有键盘输入的元素




无标题文档



Displaying Typed Characters


This document includes a simple script that displays the keys you type in the paragraph below. Type a few keys and try it.




在这里输入

网友(3):

小改动看看效果




无标题文档



Displaying Typed Characters


This document includes a simple script that displays the keys you type in the paragraph below. Type a few keys and try it.