04.11.2015 Views

javascript

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 12: Events<br />

the exact character that was inserted, so if the S key is pressed without Shift, data is “ s “ , but if the same<br />

key is pressed holding Shift down, then data is “ S ” .<br />

The textInput event can be used as follows:<br />

var textbox = document.getElementById(“myText”);<br />

EventUtil.addHandler(textbox, “textInput”, function(event){<br />

event = EventUtil.getEvent(event);<br />

alert(event.data);<br />

});<br />

In this example, the character that was inserted into the text box is displayed in an alert.<br />

As of early 2008, Safari 3 and Chrome are the only browsers that support the<br />

textInput event. For this reason, the event is not useful for cross-browser solutions.<br />

Keyboard Events on Devices<br />

The Nintendo Wii fires keyboard events when buttons are pressed on a Wii remote. Although you can ’ t<br />

access all of the buttons on the Wii remote, there are several that fire keyboard events. Figure 12 - 6<br />

illustrates the key codes that indicate particular buttons being pressed.<br />

(unavailable)<br />

175<br />

178<br />

177<br />

(unavailable)<br />

176<br />

170 174<br />

(unavailable)<br />

172<br />

173<br />

Figure 12-6<br />

396

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!