JavaScript onkeyup Event
This section illustrates you the use of onkeyup event in JavaScript.
In the given example, we are going to show you how to display the text of textField1 on the text field2 on key up. For this purpose, we have created two text fields text1 and text2. On pressing the key to write the text on the textbox1, you will see that the same text will start displaying on the textbox2. This is possible by using the onkeyup event. It occurs when a keyboard key is released.
Following code copies the value of textbox 1 to textbox2:
| document.form.text2.value = document.form.text1.value; |
Here is the code:
| <html> <h2>TextBox shows Key Event</h2> <script language="JavaScript"> function display() { document.form.text2.value = document.form.text1.value; } </script> <form name="form"> TextBox1: <input type="textbox" id="text1" onkeyup="display();"><br> TextBox1: <input type="textbox" id="text2" > </form> </html> |
Output will be displayed as:

Tutorials
- Java 26 (JDK 26) Features with examples
- Top 10 Reasons to Learn Java in 2026
- JDK 26 Tutorial
- Java Certification Roadmap 2026: Which Oracle Certs Matter
- Install JDK 26: A Complete Beginner's Guide (2026)
- What Is Java? A Complete, Up-to-Date Guide for 2026
- Java 26 HTTP3 tutorial - HTTP 3 support in JDK 26 - How to use HTTP/3 in Java 26 application?
- JDK 28 Preview: Value Objects, Shenandoah GC & JSON API
- Java Tutorials


