Users Pricing

articles

Home Articles Implementing onkeypress event in Java Script – MindStick

Implementing onkeypress event in Java Script

Anonymous User 9479 16 Mar 2011 Updated 07 Sep 2019

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


I am a content writter !


1 Comments


Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md