HTML onkeypress event properties
Examples
Run the script when you press the button:
<input type="text" onkeypress="displayResult()">
try it"
Browser Support
All major browsers support onkeypress event attributes
Definition and Usage
onkeypress property triggered when the key is pressed.
Tip: onkeypress events related to the event firing order:
- onkeydown
- onkeypress
- onkeyup
Note: onkeypress event so the browser can not trigger all the keys (for example: ALT, CTRL, SHIFT, ESC ).If only whether the user has pressed a key detection, you can use onkeydown substituted, onkeydown is triggered all the keys.
Note: onkeypress attribute can not be used with the following elements: <base>, <bdo> , <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, or <title>.
Differences between HTML 4.01 and HTML5
no.
grammar
<elementonkeypress=" script ">
Property Value
值 | 描述 |
---|---|
script | 规定该onkeypress事件触发时执行的脚本。 |
HTML Event Attributes