Listen to key up event for TextArea in JavaScript

Description

Listen to key up event for TextArea in JavaScript

Example


<html>
<head>
<script type="text/javascript">
  function handleEvent(oEvent) {<!--from   w  w w .j  a  v a 2 s . com-->
    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>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window