Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - Javascript: Up and Down Arrow Detection
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedJavascript: Up and Down Arrow Detection

 Post Reply Post Reply
Author
aj2taylo View Drop Down
Newbie
Newbie


Joined: 14 April 2003
Location: Canada
Status: Offline
Points: 9
Direct Link To This Post Topic: Javascript: Up and Down Arrow Detection
    Posted: 02 May 2003 at 8:57am
How can I use javascript to detect up and down arrow keystrokes?
Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Direct Link To This Post Posted: 02 May 2003 at 10:37am

one example:

<HTML>
<HEAD>
<SCRIPT>
function checkArrows (field, evt) {
  var keyCode =
    document.layers ? evt.which :
    document.all ? event.keyCode :
    document.getElementById ? evt.keyCode : 0;
  var r = '';
  if (keyCode == 39)
    r += 'arrow right';
  else if (keyCode == 40)
    r += 'arrow down';
  else if (keyCode == 38)
    r += 'arrow up';
  else if (keyCode == 37)
    r += 'arrow left';
  r += ' ' + keyCode;
  alert(r);
  return true;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
<TEXTAREA NAME="aTextArea" ROWS="5" COLS="20" WRAP="soft" ONKEYDOWN="return checkArrows(this, event)">
click here and then use an arrow key.
</TEXTAREA>
</FORM>
</BODY>
</HTML>

Back to Top
aj2taylo View Drop Down
Newbie
Newbie


Joined: 14 April 2003
Location: Canada
Status: Offline
Points: 9
Direct Link To This Post Posted: 05 May 2003 at 8:41am
Thanks!!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.