Does anyone know how I can detect when a key on the keyboard is pressed in .Net CF (VB).
More importantly I want to find out if I can tell if the person just pressed the key or if they held it.
Printable View
Does anyone know how I can detect when a key on the keyboard is pressed in .Net CF (VB).
More importantly I want to find out if I can tell if the person just pressed the key or if they held it.
Hi,
set the keypreview of the form to true, and catch the keydown/keypress/keyup events - that what you mean?
If the keyup doesn't fire, then they have not released the key.
Well, the theory there is right, but is there any way that I can monitor global key presses?
I have a smartphone (Palm Treo 750v) with a physical keyboard so I am trying to make an app where if the person presses and holds a key it will launch a desired app.
You can monitor for hardware keys in your app, but to launch an app by pressing a key, you would have to have your app constantly running surely.
There are 3rd party products that allow for multiple functions on a button press.
Detecting a hardware keyboard - http://blogs.msdn.com/onoj/archive/2.../12/88865.aspx
Does this help ?
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case System.Windows.Forms.Keys.Up
'Up
Case System.Windows.Forms.Keys.Down
'Down
Case System.Windows.Forms.Keys.Left
'Left
Case System.Windows.Forms.Keys.Right
'Right
Case System.Windows.Forms.Keys.Enter
'Enter
Case Else
MsgBox(e.KeyCode.ToString)
End Select
End Sub