Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Jazzo's Avatar
    Join Date
    Apr 2008
    Location
    New York City
    Posts
    164
    Thanks
    20
    Thanked 2 Times in 2 Posts

    Keystroke Commands

    I just want a simple function that redirects you to a different page upon pressing the "x" key on your keyboard. How would I do that? Replies greatly appreciated.

    Jazzo
    ~Julian
    14 y/o web developer, drummer, and Bridge player

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    Jazzo (01-19-2009)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,895
    Thanks
    202
    Thanked 2,528 Times in 2,506 Posts
    Try this:-

    <script type = "text/javascript">

    document.onkeydown = function(ev) {
    var key;
    ev = ev || event;
    key = ev.keyCode;
    if (key == 88) { // x key
    window.location = "http://www.adifferentpage.com";
    }
    }

    </script>



    "Merely corroborative detail, intended to add artistic verisimilitude to an otherwise bald and unconvincing narrative". W S Gilbert

  • Users who have thanked Philip M for this post:

    Jazzo (01-19-2009)

  • #4
    Regular Coder Jazzo's Avatar
    Join Date
    Apr 2008
    Location
    New York City
    Posts
    164
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Thanks guys!
    ~Julian
    14 y/o web developer, drummer, and Bridge player


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •