Skip to content

Instantly share code, notes, and snippets.

@jtyjty99999
Created February 7, 2014 13:18
Show Gist options
  • Select an option

  • Save jtyjty99999/8862498 to your computer and use it in GitHub Desktop.

Select an option

Save jtyjty99999/8862498 to your computer and use it in GitHub Desktop.
测试输入法事件composition
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<input type="text" name="" id="hello">
<script>
var h = document.getElementById('hello');
h.addEventListener("compositionstart", onCompositionStart,false);
h.addEventListener("compositionupdate", onCompositionUpdate,false);
h.addEventListener("compositionend", onCompositionEnd,false);
function onCompositionStart(){
console.log(1)
}
function onCompositionUpdate(){
console.log(2)
}
function onCompositionEnd(){
console.log(3)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment