Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: type a letter to execute?
06-16-2012, 10:00 PM #1
- 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?
06-16-2012, 10:19 PM #2
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.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.