Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    type a letter to execute?

    Not sure if this is even possible or if it would cause any conflicts, but I was wondering if you can trigger an event by typing a certain character. For instance, I type 'U' and a specified URL will load in the browser. Is there a way to do this?

  2. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts

    Just attach the onkeypress even to the <body> of your page and have it check for the letter(s) you are looking for.

    If you want it to work cross browser, you have to handle the even in both the normal and the MSIE-pre-version-9 ways.

    But caution: If you also have (for example) <input> form fields then typing a "U" even in them will trigger the action unless you suppress the event bubbling.
    Be yourself. No one else is as qualified.


Posting Permissions

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