473,238 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

is it possible to assign shortcut keys in javascript

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.

--
Hüseyin Ergün huseyin[at]su DOT sabanciuniv DOT edu
Sabanci University http://www.turquaz.com
Computer Science Student Tel:90-216-483 9000 / 4837
Jul 23 '05 #1
3 5199
H?seyin Erg?n wrote:

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.

--
Hüseyin Ergün huseyin[at]su DOT sabanciuniv DOT edu
Sabanci University http://www.turquaz.com
Computer Science Student Tel:90-216-483 9000 / 4837

You don't need javascript for that as long as you stick to ALT+key
combinations (so no functionkeys).
HTML provides you with the ACCESSKEY attribute just for the purpose,
though I'll admit that browser support isn't that good yet.
For more info :
http://www.cs.tut.fi/~jkorpela/forms/accesskey.html
http://www.alistapart.com/articles/accesskeys/

Grz, Juliette
Jul 23 '05 #2
Ron
H?seyin Erg?n wrote:
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.

--
Hüseyin Ergün huseyin[at]su DOT sabanciuniv DOT edu
Sabanci University http://www.turquaz.com
Computer Science Student Tel:90-216-483 9000 / 4837

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/sou...OMKeyEvent.idl
..
Jul 23 '05 #3
Ron
Ron wrote:
..., which has been standardized recently: ...


Disregard this phrase, just realized DOM2 Events doesn't support
keypress events. o_O
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Maurice Mertens | last post by:
Hi, I'm trying to set shortcut keys for textboxes. But what is the best way to do this in VB.NET. In Access it was very simple, just put an "&" sign in the label that belongs to the textbox. But...
0
by: Saper\(ek\) | last post by:
this is a strange behavior of buttons with shortcut keys, when You have a datagrid on a form and some buttons with shortcut keys. When You click on the datagrid (anywhere but the cells, free space,...
1
by: KaaN | last post by:
hi, how can i use key events in asp.net. there is a "accesskey" shortcut tag but you have to press the alt key on the keyboard with the shortcut simultaniously. can i do this without alt key? ...
2
by: philelpko | last post by:
Morning all, My database is now secure and hosted on the network and appears to be happily running thanks to several (hundred) posts on this site so thanks to everyone for the help. One person...
1
by: Emma Middlebrook | last post by:
Hi there, I'm trying to handle some shortcut keys within my application and I can't seem to get the code to work when you are trying to action against a ctrl + other character. I found a post...
0
by: thirunavukarasukm | last post by:
Hai... How to Usercontrols with Shortcut Keys... I am creating one windows apllication.. the apllication contain many form.. in one form i am used one usercontrol(parent control)..
2
by: =?Utf-8?B?SXZvODY=?= | last post by:
Hi, I need ot set hotkeys to my windows application. I want when Word is thea active application and when user press "Ctrl+Alt+T" for example to start my action. I used RegisterHotKey and...
1
sujathaeeshan
by: sujathaeeshan | last post by:
Hi all, I need to provide shortcut keys for controls like text box and buttons etc... That is i dont want to go for tabspace or mouse click for perticular controls.. By having shortcut keys i...
1
by: scudsong | last post by:
I override ProcessCmdKey() in my MDI parent form class and have some keyboard shortcut calling method in same class. But I wish to make these hotkeys working in parent/child form and other form. The...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.