DOCX

javascript_keycode

By Micheal Snyder,2014-08-13 14:19
13 views 0
javascript_keycode

enter键处发windows事件?enter键的ASCII13

    试着理解下面的一段代码,

    XML/HTML代码

    1. <script language=javascript>

    2. ie = (document.all)? true:false

    3. if (ie){

    4. function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==1

    3){this.document.form1.submit();}}

    5. }

    6. </script>

    7.

    8. <form action="http://www.jluvip.com/index.html" method=POST name=form1>

    9. <textarea cols=95 name=Content rows=12 wrap=virtual onkeydown=ctlent()>

    10. Ctrl+Enter提交内容信息

    11. </textarea>

    12. <input type=Submit value="Submit" name=Submit>

    13. </form>

    这段代码的目的就是实现通过CtrlEnter键的组合也可以发送form信息。 看到网上有些代码有使用Keycode==10?如 if(event.ctrlKey && (event.keyCode==13 ||

    event.keyCode==10)){……}

    但一直搜索不到KEYcode10是什么键?可能使用的也不会很多。

关于如何得到一个键在Javascript中的Keycode值?可以参考,

    <body onkeypress=alert(event.keyCode)>请按任意键?你将得到该键的键值)

keycode 0 =

    keycode 1 =

    keycode 2 =

    keycode 3 =

    keycode 4 =

    keycode 5 =

    keycode 6 =

    keycode 7 =

    keycode 8 = BackSpace BackSpace

    keycode 9 = Tab Tab keycode 10 =

    keycode 11 =

    keycode 12 = Clear keycode 13 = Enter keycode 14 =

    keycode 15 =

    keycode 16 = Shift_L keycode 17 = Control_L keycode 18 = Alt_L keycode 19 = Pause keycode 20 = Caps_Lock keycode 21 =

    keycode 22 =

    keycode 23 =

    keycode 24 =

    keycode 25 =

    keycode 26 =

    keycode 27 = Escape Escape keycode 28 =

    keycode 29 =

    keycode 30 =

    keycode 31 =

    keycode 32 = space space keycode 33 = Prior keycode 34 = Next

    keycode 35 = End

    keycode 36 = Home

    keycode 37 = Left

    keycode 38 = Up

    keycode 39 = Right keycode 40 = Down

    keycode 41 = Select keycode 42 = Print keycode 43 = Execute keycode 44 =

    keycode 45 = Insert keycode 46 = Delete keycode 47 = Help

    keycode 48 = 0 equal braceright

    keycode 49 = 1 exclam onesuperior

    keycode 50 = 2 quotedbl twosuperior

    keycode 51 = 3 section threesuperior

    keycode 52 = 4 dollar

    keycode 53 = 5 percent keycode 54 = 6 ampersand

    keycode 55 = 7 slash braceleft

    keycode 56 = 8 parenleft bracketleft

    keycode 57 = 9 parenright bracketright

    keycode 58 =

    keycode 59 =

    keycode 60 =

    keycode 61 =

    keycode 62 =

    keycode 63 =

    keycode 64 =

    keycode 65 = a A keycode 66 = b B keycode 67 = c C keycode 68 = d D keycode 69 = e E EuroSign

    keycode 70 = f F keycode 71 = g G keycode 72 = h H keycode 73 = i I keycode 74 = j J keycode 75 = k K keycode 76 = l L keycode 77 = m M mu keycode 78 = n N keycode 79 = o O keycode 80 = p P keycode 81 = q Q at keycode 82 = r R keycode 83 = s S keycode 84 = t T keycode 85 = u U keycode 86 = v V keycode 87 = w W keycode 88 = x X keycode 89 = y Y keycode 90 = z Z keycode 91 =

    keycode 92 =

    keycode 93 =

    keycode 94 =

    keycode 95 =

    keycode 96 = KP_0 KP_0