onkeyup event
onkeyup Event
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script> function myFunction(){ var x=document.getElementById("fname"); x.value=x.value.toUpperCase(); } </script> </head> <body> <p>当用户在输入字段释放一个按键时触发函数。函数将字符转换为大写。</p> 输入你的名称: <input type="text" id="fname" onkeyup="myFunction()"> </body> </html>
Run Instance»
Click "Run instance" button to view the online instance
Definition and usage
The onkeyup event occurs when the keyboard key is released.
Tips: The sequence of events related to the onkeyup event:
- onkeydown
- onkeypress
- onkeyup
Syntax
HTML:
<elementonkeyup="SomeJavaScriptCode">
In JavaScript:
##object.onkeyup=function(){SomeJavaScriptCode};
Description | |
---|---|
SomeJavaScriptCode | Required. Specifies the JavaScript to be executed when this event occurs.
Browser support
##All major browsers support the onkeyup event
HTML tags that support onkeyup events: