JavaScript Reference/Event Handlers Reference/onKeyDown
Версия от 18:30, 25 мая 2010; (обсуждение)
Содержание
"onKeyDown" Example
<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()">
<p>Press any key to fire the event</p>
</body>
</html>
"onKeyDown" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<a> <acronym> |
| |<address> <applet> |
| |<area> <b> |
| |<bdo> <big> |
| |<blockquote> <body> |
| |<button> <caption> |
| |<center> <cite> |
| |<code> <custom> |
| |<dd> <del> |
| |<dfn> <dir> |
| |<div> <dl> |
| |document <dt> |
| |<em> <fieldset> |
| |<font> <form> |
| |<hn> <hr> |
| |<i> <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"> |
| |<ins> <kbd> |
| |<label> <legend> |
| |<li> <listing> |
| |<map> <marquee> |
| |<menu> <nobr> |
| |<noframes> <noscript> |
| |<object> <ol> |
| |<optgroup> <option> |
| |<p> <pre> |
| |<q> <rt> |
| |<ruby> <s> |
| |<samp> <select> |
| |<small> <span> |
| |<strike> <strong> |
| |<sub> <sup> |
| |<table> <tbody> |
| |<td> <textarea> |
| |<tfoot> <th> |
| |<thead> <tr> |
| |<tt> <u> |
| |<ul> <var> |
| |<xmp> |
+----------------+--------------------------------------------------------------+
"onKeyDown" Properties
+----------------+--------------------------------------------------------------+
| Properties |altKey altLeft |
| |cancelBubble clientX |
| |clientY ctrlKey |
| |ctrlLeft keyCode |
| |offsetX offsetY |
| |repeat returnValue |
| |screenX screenY |
| |shiftKey shiftLeft |
| |srcElement type |
| |x y |
+----------------+--------------------------------------------------------------+
"onKeyDown" Syntax and Note
Note:
This event fires when the user presses any keyboard key.