Assigning keys to command buttons.
Hello all. I've been searching all over for the solution for this. Hopefully someone here can help me with a code.
Basically I want to assign the UP, DOWN, LEFT, RIGHT, and LEFT MOUSE keys to command buttons. So for example: when I click command1, it would function as the UP key, clicking command2 would function as the DOWN key, clicking command3 would function as the LEFT key, clicking command4 would function as the RIGHT key, and clicking command5 will function as the LEFT MOUSE key.
Re: Assigning keys to command buttons.
Command1 would be vbKeyUp, Command2 would be vbKeyDown, Command3 would be vbKeyLeft, Command4 would be vbKeyRight, and Command5 would be vbKeyLButton.
I'm not sure what the code would be.
Re: Assigning keys to command buttons.
Set the KeyPreview mode of the form to True, then analyze it's KeyDown event to check which key is pressed, and act on received events.
Re: Assigning keys to command buttons.
Either I or baja have this backward but it looks to me like you want to press the command button and then have something happen. You didn't say what the Up, Down, etc is acting on but here is how you'd do Up for a textbox.
Code:
Private Sub Command1_Click()
Text1.SetFocus
SendKeys "{UP}"
End Sub
Re: Assigning keys to command buttons.
It's definitely me. I just read the original post again and I got it the other way around.