Share on Google+Share on Google+

JavaScript Key Event

This page discusses - JavaScript Key Event

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:

<h2>TextBox shows Key Event</h2>
<script language="JavaScript">
function display() {
document.form.text2.value = document.form.text1.value;
<form name="form">
TextBox1: <input type="textbox" id="text1" onkeyup="display();"><br>
TextBox1: <input type="textbox" id="text2" >

Output will be displayed as:

Download Source Code:




Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: JavaScript Key Event  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
August 18, 2011