H?seyin Erg?n said:
for easy of use;
is it possible to assign Function keys or other keys as a shotcut.
For example, when user presses F2 it will click save button
automatically or vice versa.
are there ANY way of doing this?
thanks.
First, you may want to take a look at accesskeys
<
http://www.w3.org/TR/html401/interact/forms.html#adef-accesskey>. Next,
note that in many browsers, many keys have special meanings, and aside
from IE, other browsers won't allow you to cancel those events. You'll
want to create an event listener for the keypress event, which has been
standardized recently:
if(window.captureEvents) {
window.captureEvents(Event.KeyPress);
window.onkeypress = executeCode;
}
else if (window.attachEvent) {
window.attachEvent(onkeypress, executeCode);
}
function executeCode(evt) {
if(evt==null) {
evt = window.event;
} // IE doesn't pass the event object to the event listener.
var theKey = evt.keyCode;
switch(theKey) {
...
}
}
And so on. The key code differs a little between the browsers. In IE,
it's the Unicode code, while in Gecko-based, it's the list
http://lxr.mozilla.org/seamonkey/source/dom/public/idl/events/nsIDOMKeyEvent.idl
..