Connecting Tech Pros Worldwide Help | Site Map

Recognizing keystrokes?

Rico
Guest
 
Posts: n/a
#1: Mar 10 '06
Hello,

Is there any way I can tell which key was pressed in VB Code using the
OnKeyPress event? I'd like to know if the user is pressing the up, down,
left or right arrow.

Thanks!


Hansen
Guest
 
Posts: n/a
#2: Mar 10 '06

re: Recognizing keystrokes?


Hi

Your answer is in this post:
http://groups.google.co.za/group/com...40f36f9d16efba

Sorry about the line breaks. You can also search this group by typing
"Cursor Value" next to the Search This Group button

Rico
Guest
 
Posts: n/a
#3: Mar 11 '06

re: Recognizing keystrokes?


Thanks Hansen, The "Cursor Value" isn't occuring when I hit the up, down
left or right keys. If I hit the letter / number keys, the keypress is
registering, but nothing when I hit the keys I want. Any ideas?


"Hansen" <helgardh@hotmail.com> wrote in message
news:1142025744.024069.41030@z34g2000cwc.googlegro ups.com...[color=blue]
> Hi
>
> Your answer is in this post:
> http://groups.google.co.za/group/com...40f36f9d16efba
>
> Sorry about the line breaks. You can also search this group by typing
> "Cursor Value" next to the Search This Group button
>[/color]


RoyVidar
Guest
 
Posts: n/a
#4: Mar 11 '06

re: Recognizing keystrokes?


Rico wrote in message <DrCQf.26216$Ui.6883@edtnps84> :[color=blue]
> Thanks Hansen, The "Cursor Value" isn't occuring when I hit the up, down
> left or right keys. If I hit the letter / number keys, the keypress is
> registering, but nothing when I hit the keys I want. Any ideas?
>
>
> "Hansen" <helgardh@hotmail.com> wrote in message
> news:1142025744.024069.41030@z34g2000cwc.googlegro ups.com...[color=green]
>> Hi
>>
>> Your answer is in this post:
>> http://groups.google.co.za/group/com...40f36f9d16efba
>>
>> Sorry about the line breaks. You can also search this group by typing
>> "Cursor Value" next to the Search This Group button
>>[/color][/color]

Try using the KeyDown (not KeyPressed) event, and test the KeyCode

--
Roy-Vidar


Randy Harris
Guest
 
Posts: n/a
#5: Mar 11 '06

re: Recognizing keystrokes?


Rico wrote:[color=blue]
> Thanks Hansen, The "Cursor Value" isn't occuring when I hit the up, down
> left or right keys. If I hit the letter / number keys, the keypress is
> registering, but nothing when I hit the keys I want. Any ideas?
>
>
> "Hansen" <helgardh@hotmail.com> wrote in message
> news:1142025744.024069.41030@z34g2000cwc.googlegro ups.com...[color=green]
>> Hi
>>
>> Your answer is in this post:
>> http://groups.google.co.za/group/com...40f36f9d16efba
>>
>> Sorry about the line breaks. You can also search this group by typing
>> "Cursor Value" next to the Search This Group button
>>[/color][/color]


As Roy-Vidar indicated you need to use the KeyDown event to trap arrow
and function keys. KeyPress only shows ASCII values.

In KeyDown, the value KeyCode will contain:

Up-Arrow: 38
Down-Arrow: 40
Left-Arrow: 37
Right-Arrow: 39

HTH
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Rico
Guest
 
Posts: n/a
#6: Mar 11 '06

re: Recognizing keystrokes?


Excellent! Thanks guys!

"Randy Harris" <please@send.no.spam> wrote in message
news:aYDQf.58009$dW3.4099@newssvr21.news.prodigy.c om...[color=blue]
> Rico wrote:[color=green]
>> Thanks Hansen, The "Cursor Value" isn't occuring when I hit the up, down
>> left or right keys. If I hit the letter / number keys, the keypress is
>> registering, but nothing when I hit the keys I want. Any ideas?
>>
>>
>> "Hansen" <helgardh@hotmail.com> wrote in message
>> news:1142025744.024069.41030@z34g2000cwc.googlegro ups.com...[color=darkred]
>>> Hi
>>>
>>> Your answer is in this post:
>>> http://groups.google.co.za/group/com...40f36f9d16efba
>>>
>>> Sorry about the line breaks. You can also search this group by typing
>>> "Cursor Value" next to the Search This Group button
>>>[/color][/color]
>
>
> As Roy-Vidar indicated you need to use the KeyDown event to trap arrow and
> function keys. KeyPress only shows ASCII values.
>
> In KeyDown, the value KeyCode will contain:
>
> Up-Arrow: 38
> Down-Arrow: 40
> Left-Arrow: 37
> Right-Arrow: 39
>
> HTH
> --
> Randy Harris
> tech at promail dot com
> I'm pretty sure I know everything that I can remember.[/color]


Closed Thread