Java Reference
In-Depth Information
Unlike MouseEvent , the current DOM specification does not define a KeyboardEvent object for
keyboard‐related events (although one will be defined in the next version, DOM level 3). You can,
however, still access information about keyboard‐related events with the properties listed in the
following table.
properties of the
KeYboardevent objeCt
desCription
Indicates whether the Alt key was pressed when the event was
generated
altKey
Used for the keypress event. The Unicode reference number of
the key
charCode
Indicates whether the Ctrl key was pressed when the event was
generated
ctrlKey
A system‐ and browser‐dependent numerical code identifying the
pressed key
keyCode
Indicates whether the meta key was pressed when the event was
generated
metaKey
Indicates whether the Shift key was pressed when the event was
generated
shiftKey
Using the DOM Event Model
trY it out
In this Try It Out, you take a quick look at an example that uses some properties of the MouseEvent
object.
Open a text editor and type the following:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 10: Example 8</title>
<style>
.underline {
color: red;
text-decoration: underline;
}
</style>
</head>
<body>
<p>This is paragraph 1.</p>
<p>This is paragraph 2.</p>
Search WWH ::




Custom Search