Main Page

Sequencing

Sequencing
It takes a
mousedown
event followed by a
mouseup
event on the same target before a
click
event fires.
Likewise, to get a
dblclick
event to fire, it takes the following sequence of events on the same target:
1.
mousedown
2.
mouseup
3.
click
4.
mousedown
5.
mouseup
6.
click
7.
dblclick
When moving the mouse from one object to another, the first event to fire is
mouseout
(on the object that
the mouse is moving away from). Next, the
mousemove
event fires on the object between these two.
Finally, the
mouseover
event fires on the object the mouse is moving to.
Keyboard events
Keyboard events are caused by user action on the keyboard. The keyboard events are the following:
?
keydown
— Occurs when the user presses a key on the keyboard. It also occurs repeatedly as
the key is being held down.
?
keypress
— Occurs when the user presses a key on the keyboard that results in a character
(disregards keys like Shift and Alt). It also occurs repeatedly as the key is being held down.
?
keyup
— Occurs when the user releases a key that was down.
These events are most easily seen as you type in a text box, although all elements support keyboard events:
<html>
<head>
<title>Key Events Example</title>
<script type=”text/javascript”>
function handleEvent(oEvent) {
var oTextbox = document.getElementById(“txt1”);
oTextbox.value += “\n>” + oEvent.type;
}
</script>
</head>
<body>
<p>Type some characters into the first textbox.</p>
<p><textarea id=”txtInput” rows=”15” cols=”50”
onkeydown=”handleEvent(event)”
onkeyup=”handleEvent(event)”
onkeypress=”handleEvent(event)”></textarea></p>
<p><textarea id=”txt1” rows=”15” cols=”50”></textarea></p>
</body>
</html>
284
Chapter 9
12_579088 ch09.qxd 3/28/05 11:39 AM Page 284


JavaScript EditorFree JavaScript Editor     Ajax Editor


©