tailieunhanh - JavaScript Bible, Gold Edition part 93
JavaScript Bible, Gold Edition part 93. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 768 Part III Document Objects Reference each of the keyboard regardless of its character . To inspect the character of a key use the onKeyPress event to create the event object and then look at the event object s charCode property. This is the property that returns 97 for a and 65 for A because it s concerned with the character associated with the key action. This property s value is zero for onKeyDown and onKeyUp events. In contrast the keyCode property is filled with a non-zero value only from onKeyDown and onKeyUp events onKeyPress sets the property to zero when alphanumeric keys are pressed for most other non-character keys all three events fill the keyCode property. Through this property you can look for non-character keys such as arrows page navigation and function keys. For the character keys there is no distinction between uppercase or lowercase The A key on the Latin keyboard returns a value of 65 regardless of the state of the Shift key. At the same time however the press of the Shift key fires its own onKeyDown and onKeyUp events setting the keyCode value to 16. Other non-character keys arrows page navigation function and similar have their own codes as well. This gets very detailed including special key codes for the numeric keyboard keys that are different from their corresponding numbers along the top row of the alphanumeric keyboard. Be sure to see the extensive section on keyboard events in Chapter 15 for examples of how to apply the keyCode property in applications. Example with Listing 29-18 on the CD-ROM On the CD-ROm Related Items onKeyDown onKeyPress onKeyUp event handlers. clientX clientY layerX layerY pageX pageY screenX screenY Value Integer Read-Only NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility The NN6 event object borrows mouse coordinate properties from both the NN4 and IE4 event models. If you have worked with event coordinates in these other browsers then you have nothing new to learn for NN6. NN6 .
đang nạp các trang xem trước