473,652 Members | 3,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5212
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
automaticall y 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.captu reEvents) {
window.captureE vents(Event.Key Press);
window.onkeypre ss = executeCode;
}
else if (window.attachE vent) {
window.attachEv ent(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
3334
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 in VB.NET it looks like you have to program code for the shortcut keys. Like putting this code in the Form_KeyUp: If e.Alt And e.KeyCode = Keys.L Then Me.ActiveControl = Me.TextBox1
0
1739
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, header or something) and press the shortcut key (without the ALT key pressed) button's action is called. You can easyli recreate this by creating a simple project with datagrid and a button with shortcut key (&Delete in the Text property for...
1
1538
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? KaaN
2
11744
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 unfortunately did some final destructive testing for me which seem to consist of nothing more than hitting random keys on the keyboard. This, to my horror, unfortunately this found a fault. Shortcut keys. I have found a few threads online but...
1
2903
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 http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/a0bfd442d01f715f/27cbc8062c107680?lnk=gst&q=c%23+shortcut+key+ctrl&rnum=3&hl=en#27cbc8062c107680 that appears to help a lot but it doesn't seem to work...
0
2643
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
2428
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 UnregisterHotKey methods and ovverride WndProc but even when user works with another program different than MS Word and press the shortcut key my action is done. Thanks
1
1686
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 need to go for specifeid controls(textbox,button)... Is there any way to provide shotcut keys for controls.....or built in property values..... could any anoe help me out of this query...
1
4152
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 case now is when focus on the other form(regular form, not MDI), ProcessCmdKey() doesn't capture keyboard anymore. Which class should I put ProcessCmdKey() in and anything to make it work? Thanks! namespace myNamespace { public class...
0
8367
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.