Java Reference
In-Depth Information
addEventListener("keydown", function(event) {
if (event.keyCode == 32 && event.ctrlKey)
console.log("Action cancelled!");
The following code checks to see if the Shift key was held down when the mouse was
addEventListener("click", function(event) {
if (event.shiftKey)
console.log("A Shifty Click!");
Warning: Take Care When Using Modifier Keys
Many of the modifier keys already have a purpose assigned in the browser
or operating system. And although it's possible to prevent the default beha-
vior in the browser (see later in this chapter), it's not considered best prac-
tice to do so.
Touch Events
Many modern devices now support touch events . These are used on smart phones and tab-
lets, as well as touch-screen monitors, satellite navigators, and trackpads. Touch events are
usually made with a finger, but can also be by stylus or another part of the body. There are
a number of touch events that cover many types of touch interactions.
It's important to support mouse events as well as touch events, so that non-touch devices
are also supported. With so many different devices available these days, you can't rely on
users using just touch or just a mouse. In fact, some devices, such as touchscreen laptops,
support both mouse and touch interactions.
The touchstart event occurs when a user initially touches the surface.
Search WWH ::

Custom Search