Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
how to catch keyboard scrolling buttons event?
ankur rathi
Ranch Hand
Posts: 3852
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
onKeyPress
is for all the buttons, I need sth specific to up, down, right and left arrow key.
TIA.
Eric Pascarello
author
Posts: 15385
6
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Look at the keycode of the presses. They have ids.
Eric
ankur rathi
Ranch Hand
Posts: 3852
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Originally posted by Eric Pascarello:
Look at the keycode of the presses. They have ids.
Eric
Thanks Eric.
But surprisingly, I am able to capture all the keys except up, down, right and left arrow key.
<html> <body onkeypress_CHANGED = "show_key(event.which)"> <form method="post" name="my_form"> The key you pressed was: <input type="text" name="key_display" size="2"> </form> <script language="JavaScript"> function show_key (the_key) { if (!the_key) { the_key = event.keyCode; } alert(the_key); alert(String.fromCharCode(the_key)); document.my_form.key_display.value = String.fromCharCode (the_key); } </script> </body> </html>
Eric Pascarello
author
Posts: 15385
6
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<script> function handleKeyPress(evt) { var nbr, chr; if (window.Event) nbr = evt.which; else nbr = event.keyCode; alert(nbr); return true; } document.onkeydown= handleKeyPress </script>
Eric
ankur rathi
Ranch Hand
Posts: 3852
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks a ton Eric.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Convert working program to display in GUI
an array of buttons in an applet ?
About GUI
What is it with the necktie?
calling another GUI class
More...