articles

Home / DeveloperSection / Articles / Implementing onkeypress event in Java Script

Implementing onkeypress event in Java Script

Anonymous User8521 16-Mar-2011

onkeypress event is called when ever any key is pressed in control. Normally we use onkeypress event to check that which key is pressed by user or when we want to make key logger type application. The following section gives you a simple demonstration in which we can use concept of onkeypress event in java script. Write down following code to create a user interface in java script.

Create an user interface in html
<body>
    <p><textarea id="TextArea1" cols="20" name="S1" rows="2" onkeypress="copyText()"></textarea></p>
    <p><textarea id="TextArea2" cols="20" name="S2" rows="2"></textarea></p>
</body>
Create a method in java script and call this method at onkeypress event
<script type="text/javascript">
        function copyText() {
            TextArea2.value = TextArea1.value;
        }
</script>
Output of the following code snippet is as follows

Implementing onkeypress event in Java Script

Implementing onkeypress event in Java Script


Updated 07-Sep-2019
I am a content writter !

Leave Comment

Comments

Liked By