Created
April 12, 2013 02:02
-
-
Save thirdj/5368721 to your computer and use it in GitHub Desktop.
onkey events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| onkeydown - 모든 키를 눌렀을때(shift, alt, control, capslock 등의 키도 모두 인식한다. 단 한영변환,한자 등의 특수키는 인식못함.) | |
| onkeyup - 모든 키를 눌렀다 땠을때(onkeydown 에서 인식하는 키들을 인식) | |
| onkeypress - 실제로 글자가 써질때 (shift, enter 같은 키는 인식하지 못한다) | |
| */ | |
| document.getElementById('id').onkeyup=function(e){ | |
| var event = e || window.event; | |
| console.log('event '+ event); | |
| }; | |
| //ie 와 ff keyevent 차이 | |
| function mykey(e) { | |
| var keycode = ''; | |
| if(window.event) keycode = window.event.keyCode; | |
| else if(e) keycode = e.which; | |
| else return; | |
| alert(keycode); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment