JavaScript Reference/Event Handlers Reference/onKeyDown

Материал из Web эксперт
Перейти к: навигация, поиск

"onKeyDown" Example

   <source lang="javascript">
   

<html> <head> <script language="JavaScript"> function function1() {

   msg = "on" + event.type + " event fired by " + """ + event.srcElement.id + """; 
   alert(msg) 

} </script></head> <body id="myBody" onkeydown="function1()">

Press any key to fire the event

</body> </html>


     </source>
   
  


"onKeyDown" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> | | | |

| |
<body> |

| |<button> |

| |
|

| | <custom> | | |

| | | <dir> |

| |
|

| |document

| | | <fieldset> | | | <form> |

| |<hn>
|

| | <input type="button"> | | |<input type="checkbox"> <input type="file"> | | |<input type="image"> <input type="password"> | | |<input type="radio"> <inputtype="reset"> | | |<input type="submit"> <input type="text"> | | | | | |<label> <legend> |

| |
  • <listing> | | |<map> <marquee> | | |<menu> <nobr> | | |<noframes> <noscript> | | |<object>
      | | |<optgroup> <option> | | |

                               |
      |                |                                                       |
      |                |                                                     |
      |                |                          <select>                      |
      |                |                                                 |
      |                |                                              |
      |                |                                                    |
      |                |                         <tbody>                       |
      |                |                          |
      |                |                                                       |
      |                |
        | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>

        "onKeyDown" Properties

        <source lang="javascript"> +----------------+--------------------------------------------------------------+ | Properties |altKey altLeft | | |cancelBubble clientX | | |clientY ctrlKey | | |ctrlLeft keyCode | | |offsetX offsetY | | |repeat returnValue | | |screenX screenY | | |shiftKey shiftLeft | | |srcElement type | | |x y | +----------------+--------------------------------------------------------------+

        </source>



        "onKeyDown" Syntax and Note

        <source lang="javascript"> Note:

        This event fires when the user presses any keyboard key.

        </source>

      <textarea> | | |<tfoot> | | |<thead>