Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bound keyboard key to JS-function

Status
Not open for further replies.

michelledebeer

Programmer
Oct 26, 2001
22
0
0
SE
I would like to take control over a key on the keyboard, namely F1.

Can I with JavaScript call a function that opens a new window when someone hits this button like that annoying mouse-right-button-click that usually says "Don't mess with the source"?

The only difference is that this will not be annoying, but useful. :)

Any thoughts?
// Michelle
 
But it WILL be annoying if I try to use the F1 key that's pretty much universally used for Windows-based help files, and I get what you decided the F1 key should do. What about other keys that are either normal Windows or program hotkeys, or that users have programmed to be hotkeys for themselves? Changing keyboard responses is pretty much a sure way to annoy people, along with popups and a few other "tricks" that relatively new web programmers/designers find attractive.
 
This is a function that is limited to the service we provide and the F1 key is the key the one we have desided to use, because it will open a help-window for our service.

Since people are used to pressing the F1 key for help, this will not be annoying to most people, but a way for them to feel comfortable with an interface they are familiar with. This is one of the key elements of a good user interface.

Of course there will be an option to disable this feature for those who don't want it.

I agree that changing the keyboard response "d" to print out an alert "You just started writing Dick, he he he", is annoying and plain stupid if you want any credability for your service.

As I see it, programming is completely useless if you have a faulty user interface, and programming for the sake of programming is a waste of time.

So... Anyone know how to do it?

// Michelle
 
Works in IE, but doesn't stop IE's Help window from opening.
<body onkeydown=&quot;if(event.keyCode==112){window.open('help.html')}&quot;>
 
hi Michelle,

window.onhelp = function(){alert(&quot;no help window!&quot;);return false;}

only works in IE I believe.

=========================================================
if (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top