Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' 
        src='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js'></script>
 <script>
   
  $(function() {
    
  var $log = $("#dvLog");
    
  $("#txtTest").bind("keypress", function (e) {
    
      $log.append("<div>KeyPress e.which: " + e.which + "<br>" + "keyCode: " + e.keyCode + ", charCode: " + e.charCode + "<div>");
    
    }).bind("keydown", function (e) {
    
      $log.append("<div>KeyDown e.which: " + e.which + "<br>" + "keyCode: " + e.keyCode + ", charCode: " + e.charCode + "<div>");
    }).bind("input", function (e) {
    
      $log.append("<div>input<div>") 
      console.log("key: " + e.key + ", char: " + e.char)
      
    });
    
    $("#btnClear").click(function() { 
      $log.empty(); 
    });
    
    $("#txtTest").bind("input", function(e) {
      
      var u = this.value; //可取得目前的文字內容
      console.log(u)
      
    });
  });
  </script>
</head>
<body>
<input type="text" id="txtTest" />
<input type="button" id="btnClear" value="clear" />
<div id="dvLog" style="border: 1px solid red; font-size: 9pt;"></div>
</body>
</html>
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers