首先
这句的 onKeyPress 多余了,因为上面的 JS 代码已经给他绑定。
其次,因为这个
不可编辑,所以不会产生 keypress 事件。
给你改一下程序,监听 window 的 keypress,显示在指定区域。
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.