• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Capture ENTER on number and not main keyboard

Is it possible to programatically know the difference from when the ENTER key on the number pad is pressed rather that the ENTER key on the main part of the keyboard.  Client is wanting to use the ENTER on the number pad as a TAB and the ENTER key on the main part of the keyboard as the normal ENTER key function
0
Adam95GTS
Asked:
Adam95GTS
1 Solution
 
Bob LearnedCommented:
AFAIK, the answer is no.
0
 
Adam95GTSAuthor Commented:
Was afraid of that.
0
 
Bob LearnedCommented:
Sometimes, you have to take a step back and analyze customer requests to see "why" they want to do things, and try to talk them out of "non-standard" behavior for software.  We get those kind of requests all the time, and I have learned to ignore most of them.

There is supposed to be a difference in the Virtual Key code, but experience has shown that to not be the case.  There may still be some magic out there, but I haven't found it yet.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
zzzzzoocCommented:
I think i've seen games that implement an extended Enter (NumPad) and regular Enter for keyboard mapping, not sure how though. Might be possible with a keyboard-hook if it allows KEYEVENTF_EXTENDEDKEY checks.

But, you could just have the user press the NumLock when they wish to use the NumPad enter. Then you can just check the state of the NumLock to differ between the two.

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
        If GetKeyState(vbKeyNumlock) = 1 Then
            MsgBox "Enter Pressed (NumPad)"
        Else
            MsgBox "Enter Pressed"
        End If
    End If
End Sub
Private Sub Form_Load()
    Me.KeyPreview = True
End Sub
0
 
Bob LearnedCommented:
Bending to customer requests can make you invent some crazy stuff!!
0
 
mazfarCommented:
The solution is given in a microsoft article at the link below:

http://support.microsoft.com/default.aspx?scid=kb;en-us;188550

ciao
0
 
Bob LearnedCommented:
Like I said there is some magic out there that I hadn't found yet.  There is always room to learn.
0
 
fantasy1001Commented:
Adam, mazfar has the correct and direct answer. Well done!
0
 
Adam95GTSAuthor Commented:
Excellant, thanks alot for the help!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now