Peipei Wong 10月 10, 2020
• 在其它设备中阅读本文章

<Input
onKeyPress={keyPress}
onKeyDown={keyDown}
/>


keypress event的定义

The keypress event is fired when a key that produces a character value is pressed down. Examples of keys that produce a character value are alphabetic, numeric, and punctuation keys. Examples of keys that don’t produce a character value are modifier keys such as Alt, Shift, Ctrl, or Meta.

keydown event的定义

The keydown event is fired when a key is pressed.
Unlike the keypress event, the keydown event is fired for all keys, regardless of whether they produce a character value.

Returns a Number representing a system and implementation dependent numeric code identifying the unmodified value of the pressed key