2007-07-05から1日間の記事一覧

Firefoxの場合

eventではなくeを使うのがみそ。 また、e.keyCodeとe.charCodeがある。IMEを効かせていると取れる値が違うので注意。 <script type="text/javascript"> document.onkeypress = key_Press function key_Press(e){ keycode = e.which; alert(keycode); keychar = String.fromCharCode(keycode)</script>…

キーボード入力文字を表示するJavaScript

<html> <script type="text/javascript"> document.onkeypress = key_Press function key_Press(e){ alert(String.fromCharCode(event.keyCode)); } </script> <body bgcolor="#ffffff"> </body> </html>