Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 776
  • Last Modified:

Hotkey - SPACE BAR

I use KeyPreview = True for form

Then have:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then
 etc etc

Problem - if i run the program it performs the keydown event ok but also any command button that has the focus at the time - no good

How to simply get the SPACE BAR to perform something on its own ?
0
clapper100497
Asked:
clapper100497
  • 2
  • 2
1 Solution
 
DrDelphiCommented:
Try this:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then
   MsgBox "Space key pressed"
   KeyCode = 0
End If



Good luck!!
0
 
clapper100497Author Commented:
KeyCode = 0 did the trick !
Well done and thanks !!!!
0
 
clapper100497Author Commented:
Thanks for such a simple solution
Appreciated !!!
0
 
DrDelphiCommented:
Cheers.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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