VirtualMV/JavaScript/Interactivity
From WikiEducator
< VirtualMV | JavaScript
Overview
This page describes techniques to add interactivity to your web page
Adding Interactivity in JavaScriptBy the end of this page you will be able to:
|
Detecting a keypress
Be aware that you can get the browser tangled if you use Browser trigger keys (e.g. F11 makes the Browser go full screen). If you are using an editor plug-in the editor may use hotkeys also (e.g. Home, End).
- Some additional resources:
<head> <title>onkeydown example</title> <Meta name="author" content="M Verhaart (2010) virtualmv.com"> <script type="text/javascript" > /** Detect keydown ======================================== */ document.onkeydown = function( e ) { if( e == null ) e = event; var intKey = fnGetKey( e ); document.frmMain.txtShowKey.value = intKey; } function fnGetKey( e ) { if( window.createPopup ) //createPopup only exists in IE return e.keyCode else return e.which } </script> </head> <body> <form name="frmMain"> <p>Press a key</p> Key value <input type="text" name="txtShowKey" value=""> </form> </body> <html>
Example :Click here to run jsInt_onkeydown.htm.
References
- ↑ Hotkeylist (2010). Internet Explorer Hotkey, IE Browser Hotkeys, Shortcut Keys. Retrieved March 14, 2010 from http://hotkeyslist.com/internet-explorer-hotkey-ie-browser-hotkeys-shortcut-keys/
- ↑ Koch, P-P. (n.d.) Detecting keystrokes. Retrieved March 14, 2010 from http://www.quirksmode.org/js/keys.html
- ↑ Cooper, R. (n.d.) Javascript keyCode checker tool. Retrieved March 14, 2010 from http://www.ryancooper.com/resources/keycode.asp
virtualMV | Superquick wiki guide | Please give me some feedback |
VirtualMV/JavaScript/Interactivity. (2024). In WikiEducator/VirtualMV wiki. Retrieved December 22, 2024, from http:https://wikieducator.org/VirtualMV/JavaScript/Interactivity (zotero)
|