IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Keyboard remapping.
Okay, gurus, next problem: I am doing a data entry app in Access (2k). I'm trying to have the keyboard "mapped" so that the numeric keypad is within the regular QWERTY space (u, i, o = 1, 2, 3; j,k,l = 4,5,6, etc.). Some fields are all numeric and we want them to autotab (using input masks like '###'). Others are alphanumeric (e.g., address fields) where we want them to be able to hold the shift key to put the numeric keypad letters back to letters (all caps).

I tried doing it with a bit of code using the Keypress event, and converting the keypresses on the fly, sort of mimicking a remap, using this procedure:

Public Sub NumRemap(KeyAscii As Integer)
' On-the-fly keyboard remapping to put the numeric keypad within the main keyboard space
Select Case KeyAscii
Case 117: SendKeys "1"
Case 105: SendKeys "2"
Case 111: SendKeys "3"
Case 106: SendKeys "4"
Case 107: SendKeys "5"
Case 108: SendKeys "6"
Case 109: SendKeys "7"
Case 44: SendKeys "8"
Case 46: SendKeys "9"
Case 97 To 104, 110 To 122: SendKeys Chr(KeyAscii - 32)
End Select
End Sub

The 97-104 and 110-122 converts lower case to upper case.

Works fine for purely numeric controls with an input mask of '###'. Trouble is, in any other controls it goes whacked. It double-enters keys unless the shift key is also pressed. E.g., pressing 'a' puts an 'aA' in the control.

I tried using the KeyDown, but that results in it doing nothing.

New Re: Keyboard remapping.
Ahhhhhhh. . . . .it is always sending two keys to the control, the original keypress and then the SendKeys one, but when it's masked for Numeric-only, it just accepts the numeric one.

Okay, now the question is, How does one capture the initial key before it goes to the control and only send the one I want?
New Re: Keyboard remapping.
I think you'll have to write a keyboard interrupt handler and process the scancodes yourself.

unless you can remap the keyboard in the "International Settings" section...
-drl
New Gazillion levels between Access 2000 and keyboard interrupt
I know how to do it in MFC or Windows SDK code, but not in Access...
--

"There's nothing more nervous than a million dollars. It does not speak French, it does not speak English, it does not speak German and it moves very fast."

-- Jean Chretien
New rofl
Come on, Ark, let's write a KIH in Access!

-drl
New May have got it.


I had to use the KeyDown event to change the UIOJKLM,. keys to numbers if the Shift key was NOT depressed:

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

' If Shift-only is pressed (Keycode=16) then do nothing. Otherwise, convert depending on
' status of shift key
If KeyCode <> 16 Then
If Shift = 0 Then ' Shift key NOT pressed; convert numeric keys to numbers, everything else to CAPS
Select Case KeyCode
Case 85: KeyCode = 49
Case 73: KeyCode = 50
Case 79: KeyCode = 51
Case 74: KeyCode = 52
Case 75: KeyCode = 53
Case 76: KeyCode = 54
Case 77: KeyCode = 55
Case 188: KeyCode = 56
Case 190: KeyCode = 57
' Case 65 To 72, 78, 80 To 90: KeyCode = (KeyCode - 32)
End Select
' Else ' Shift key PRESSED; convert everything to CAPS
End If
End If 'Keycode<>16, i.e., Shift-only pressed


And then the KeyPress event to automatically convert everything else to upper case:
Private Sub Text0_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 97 To 122: KeyAscii = (KeyAscii - 32)
End Select


So it's still kind of a keyboard interrupt but it only changes the KeyCode for the ones I need to be numeric.

New Final update.
Well, I finally got it all figured out. Turned into 3 functions altogether. The key (so to speak) was learning what the KeyCode (from the KeyDown event) and KeyAscii (from the KeyPress event) values actually represented. So I have two functions for converting the "UIOJKLM,." keys to numbers or uppercase characters, depending on whether the control is alphanumeric or numeric-only and whether the Shift key is pressed.
New Re: Final update.
And we hope it's localized to the application :)
-drl
New Re: Final update.
Oh, most definitely.

BTW, does anyone know what the F8 key does when in a form?
New I do now (re: F8).
F8
To turn on Extend mode (EXT appears in the lower-right corner of the window); pressing F8 repeatedly extends the selection to the word, the field, the record (in Datasheet view only), and all records

LEFT ARROW or RIGHT ARROW
To extend a selection to adjacent fields in the same row in Datasheet view

UP ARROW or DOWN ARROW
To extend a selection to adjacent rows in Datasheet view

SHIFT+F8
To undo the previous extension

ESC
To cancel Extend mode
--
Chris Altmann
     Keyboard remapping. - (acagle) - (9)
         Re: Keyboard remapping. - (acagle) - (4)
             Re: Keyboard remapping. - (deSitter) - (3)
                 Gazillion levels between Access 2000 and keyboard interrupt - (Arkadiy) - (1)
                     rofl - (deSitter)
                 May have got it. - (acagle)
         Final update. - (acagle) - (3)
             Re: Final update. - (deSitter) - (2)
                 Re: Final update. - (acagle) - (1)
                     I do now (re: F8). - (altmann)

I made you eggs. Straight from my womb to your plate!
151 ms