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>
Anonymous User
03-May-2019Thanks for sharing.