Keycode for uppercase letters

T

tim johnson

I would like to identify with the KeyDown event when a
user enters lowercase i and o and upper case I and O.

I have been able to get the lowercase keycode as 73 and
79. I am having a problem for uppercase because I have to
hold the Shift key down and this complicates it.

How can I get the keycode for uppercase I and O using the
KeyDown procedure?

Thanks
 
S

Sandra Daigle

You need to check the value of the Shift parameter. To do this you do a
bitwise AND with the appropriate mask to determine which of the Ctl, Alt &
Shift keys are down.

Dim fShift As Boolean 'True when Shift key is down
Dim fAlt As Boolean 'True when Alt key is down
Dim fCtl As Boolean 'True when Ctl key is down
fShift = Shift And acShiftMask
fAlt = Shift And acAltMask
fCtl = Shift And acCtrlMask

With this you can do your comparison:

if keycode=vbkeyI and fShift then
msgbox "It is uppercase I"
endif
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top