Connecting Tech Pros Worldwide Help | Site Map

hotkeys

Bernd Eichelsdorf
Guest
 
Posts: n/a
#1: Jun 9 '06
Hi,

I would like to add hotkeys to my webapp -
it's running on a barcode scanner, that has got
a number pad and the keys F1 - F4.
I would like to add hotkeys, so that
when the user presses F1, the focus is
set on form field 1 and so on...

Is that possible with javascript, if so, how?

Thx,

Bernd
Robert
Guest
 
Posts: n/a
#2: Jun 9 '06

re: hotkeys


Bernd Eichelsdorf wrote:[color=blue]
> Hi,
>
> I would like to add hotkeys to my webapp -
>
> Is that possible with javascript, if so, how?[/color]

Yes, it is possible.
Take a look at
http://www.w3.org/2002/09/tests/keys.html

And you also may need to prevent the default action in an event handler

if (event.preventDefault)
event.preventDefault();
else
event.returnValue = false; // IE
Bernd Eichelsdorf
Guest
 
Posts: n/a
#3: Jun 11 '06

re: hotkeys


Robert schrieb:[color=blue]
> Bernd Eichelsdorf wrote:[color=green]
>> Hi,
>>
>> I would like to add hotkeys to my webapp -
>>
>> Is that possible with javascript, if so, how?[/color]
>
> Yes, it is possible.
> Take a look at
> http://www.w3.org/2002/09/tests/keys.html
>
> And you also may need to prevent the default action in an event handler
>
> if (event.preventDefault)
> event.preventDefault();
> else
> event.returnValue = false; // IE[/color]


Sorry, I don't understand.
When I press F1, it tells me:
Data keydown keypress keyup
keyCode 67 0 ---

but how can I do this myself, that
I know if the user has pressed F1?
Randy Webb
Guest
 
Posts: n/a
#4: Jun 11 '06

re: hotkeys


Bernd Eichelsdorf said the following on 6/11/2006 2:28 AM:[color=blue]
> Robert schrieb:[color=green]
> > Bernd Eichelsdorf wrote:[color=darkred]
> >> Hi,
> >>
> >> I would like to add hotkeys to my webapp -
> >>
> >> Is that possible with javascript, if so, how?[/color]
> >
> > Yes, it is possible.
> > Take a look at
> > http://www.w3.org/2002/09/tests/keys.html
> >
> > And you also may need to prevent the default action in an event handler
> >
> > if (event.preventDefault)
> > event.preventDefault();
> > else
> > event.returnValue = false; // IE[/color]
>
>
> Sorry, I don't understand.
> When I press F1, it tells me:
> Data keydown keypress keyup
> keyCode 67 0 ---
> but how can I do this myself, that
> I know if the user has pressed F1?[/color]


You check the keycode that triggered it and see if it is 67. If it is,
then you know they pressed F1.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Closed Thread


Similar JavaScript / Ajax / DHTML bytes