472,119 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Recognizing keystrokes?

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!
Mar 10 '06 #1
5 1848
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

Mar 10 '06 #2
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" <he******@hotmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...
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

Mar 11 '06 #3
Rico wrote in message <DrCQf.26216$Ui.6883@edtnps84> :
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" <he******@hotmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...
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


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

--
Roy-Vidar
Mar 11 '06 #4
Rico wrote:
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" <he******@hotmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...
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

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.
Mar 11 '06 #5
Excellent! Thanks guys!

"Randy Harris" <pl****@send.no.spam> wrote in message
news:aY******************@newssvr21.news.prodigy.c om...
Rico wrote:
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" <he******@hotmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...
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

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.

Mar 11 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Olli Piepponen | last post: by
2 posts views Thread by Steven Raasch | last post: by
5 posts views Thread by Lucas Tam | last post: by

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.