Listen to key up event for TextArea in JavaScript
Description
The following code shows how to listen to key up event for TextArea.
Example
<html>
<head>
<script type="text/javascript">
function handleEvent(oEvent) {<!-- ww w . jav a2 s. c om-->
var oTextbox = document.getElementById("txt1");
oTextbox.value += "\n>" + oEvent.type;
}
</script>
</head>
<body>
<P>Type some characters into the first textbox.</p>
<P><textarea id="txtInput" rows="15" cols="50"
onkeydown="handleEvent(event)"
onkeyup="handleEvent(event)"
onkeypress="handleEvent(event)"></textarea></p>
<P><textarea id="txt1" rows="15" cols="50"></textarea></p>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Key Event
Check if Alt key is pressed during the even...
Check if Shift key is pressed during the ev...
Check if the Control key is pressed during ...
Convert the key code from key event to char...
Get key event target element id in JavaScri...
Get the key char from the key event in Java...
Get the key code from key event in JavaScri...
Get the key event target or event source in...
Listen to body on key down event in JavaScr...
Listen to key down event for TextArea in Ja...
Listen to key down event for input text ele...
Listen to key press event for TextArea in J...
Check if Alt key is pressed during the even...
Check if Shift key is pressed during the ev...
Check if the Control key is pressed during ...
Convert the key code from key event to char...
Get key event target element id in JavaScri...
Get the key char from the key event in Java...
Get the key code from key event in JavaScri...
Get the key event target or event source in...
Listen to body on key down event in JavaScr...
Listen to key down event for TextArea in Ja...
Listen to key down event for input text ele...
Listen to key press event for TextArea in J...