Extended Keyboard Arrows Keycode

AndyMo
01-24-2005, 09:08 PM
Hello,

I have discovered on my one computer that the extended keyboard arrow keys are returning a keycode of 255 when the numlock is on. I am guessing that this is part of a two-part sequence to differentiate between the numpad arrow keys and the extended arrow keys.

In any event, I would like to be able to read the extended arrow keys regardless of the numlock state. I would like to not toggle the numlock on the user if I do not have to.

Is this a two-part sequence ? And if so, how can I get the second code ?

Thanks in advance,

Andy

webbone
01-24-2005, 10:03 PM
How are you getting this 'keycode'? Are you referring to the KeyDown/KeyUp event for a particular control?

On this particular computer I get the same KeyCode value for the cursor keys regardless of the state of NumLock.

Can you post the code that you are having trouble with so we can help you find the problem?

Rockoon
01-25-2005, 03:07 AM
I'm assuming he is using the arrows on the keypad itself rather than the 4 seperate arrows usualy to the left and below the keypad.

AndyMo
01-25-2005, 08:33 AM
Thanks for replying. Here is the code from my testing program...

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

MsgBox "keycode " & KeyCode & " shift " & Shift

End Sub

The numeric pad functions properly: with numlock on I get the ascii for 2, 4, 6 and 8 (ascii 98, 100, 102, and 104 respectively). With numlock off I get ascii 40, 37, 39, 38 (down, left, right and up arrows respectively).

The problem is with the 4 arrow keys all by themselves (usually found between the numeric keypad and the main keyboard area). Even though the num lock is normally just associated with the numeric keypad, it seems to be affecting the stand alone arrow keys as well. With numlock off the arrow keys return 40, 37, 39, 38 normally, but with the numlock on the arrow keys return 255, 255, 255, and 255. (??).

I have also just noticed today that this problem does not occur on my Windows 2k machine at work (generic keyboard). The problem always is present on my home XP machine with a Logitech x700 wireless keyboard.

Thanks in advance !

... Andy

webbone
01-25-2005, 11:36 PM
It sounds like this might be a keyboard related issue (or keyboard driver related issue). As a hardware design engineer I can see WHY someone might end up creating this situation due to the way the keyboard is designed electronically.

Out of curiosity I just fired up an old Win98 machine and tried this out - I don't get ANY KeyDown events from the arrow keys (either the T or the NumPad) regardless of the state of NumLock! This has me thinking this is device driver related which would also make it quite possibly OS dependent. Hmmm... I'll post back if I get any other clues!

AndyMo
01-26-2005, 06:17 AM
Thanks for posting ! Hmmm... I think you could be right in that it may be a hardware issue. Strangely applications like Word respond to the extended arrow keys all the time, so there is SOME standard signal going out. I guess the question then becomes can we read it with VB ?

Thanks again

lazerfisk
01-26-2005, 09:40 AM
Just a thought.... GetAsyncKeyState? (http://www.mentalis.org/apilist/GetAsyncKeyState.shtml) :)

Cheers,
Christopher

AndyMo
01-30-2005, 08:37 PM
Just a thought.... GetAsyncKeyState?

Thanks. I tried it and it seems a bit tricky. The documentation is not too clear, but from my mucking around it I can match the keycodes when async goes to -32767 (?). I'll finish plugging it in and try it on the offending keyboard...

webbone
01-30-2005, 09:50 PM
You might want to check out my posts here: http://www.xtremevbtalk.com/showthread.php?t=164690&highlight=GetKeyState

You don't actually check for the return value being EQUAL to a specific value - you need to check to see if a particular bit is SET to see if the key is down.

AndyMo
01-31-2005, 08:29 PM
You might want to check out my posts here: http://www.xtremevbtalk.com/showthread.php?t=164690&highlight=GetKeyState


I like that API, and I learned something new! Unfortunately it does not solve my problem. Both GetKeyState and GetAsynch return keycode 255 for the %#$% extended arrow keys. (it recognizes all other keys okay).

*sigh*

I'm thinking it has to be the Logitech keyboard. But that doesn't explain how the MS programs don't have a problem with it.

webbone
01-31-2005, 10:50 PM
Since your micro$ programs seem to know how to use it, have you checked online to see if there is an updated driver available for your keyboard? Just a thought but perhaps that is the issue.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum