/    Sign up×
Community /Pin to ProfileBookmark

alt + key for menu in js

hello guys

i have really a problem

i have a menu with css and of course each element is a link < a >

i want and need that if i press alt + [b]b[/b]
the link
[i][b]b[/b]est prices[/i] get the focus,

alt + [b]s[/b]
[i][b]s[/b]upport[/i]

so if this link has a submenu it should open or show the submenu of course
if not has a submenu so it must call the url content in the link

so problem is how i can use or able to work with
alt + [b]some key[/b]

thanks in advanced

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@DokAug 30.2007 — Do something like this
[CODE]function handleKey(e) {
// If IE
if (!e)
e = event;
// If ALT key is pressed
if (e.altKey) {
// Switch on the keyCode (the Unicode for the character pressed)
switch(e.keyCode) {
// Your code goes here
}
}
}

document.body.onkeyup = handleKey;[/CODE]
Copy linkTweet thisAlerts:
@dr_pompeiiauthorSep 01.2007 — thanks for all

i am testing your way and works

thanks!
Copy linkTweet thisAlerts:
@artemisSep 01.2007 — This ability is actually supported in HTML, see:

http://www.htmlcodetutorial.com/linking/_A_ACCESSKEY.html

http://en.wikipedia.org/wiki/Access_keys

So no need for JavaScript!
Copy linkTweet thisAlerts:
@dr_pompeiiauthorSep 01.2007 — hello artemis

try it in opera or firefox, doesnt work, only work in IE

if i am wrong

copy here a simple sample for a link with

[CODE]
<html>
<head>
</head>
<body>
<UL>
<LI><A HREF="../" ACCESSKEY="H">Home</A>
<LI><A HREF="_A.html" ACCESSKEY="A">Anchor</A>
<LI><A HREF="../quicklist.html" ACCESSKEY="Q">QuickList</A>
</UL>
</body>
</html>
[/CODE]

simply it capture the key of the browser itself (H of History for instance)
×

Success!

Help @dr_pompeii spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...