Use Keyboard with KeyDown and KeyUp

D

Donny

I am working on a sheet that has keyboard shortcuts. I want to use
keyboard buttons to control the worksheet. For example, if I press
the "q" key down, I want TextBox1 to appear. When the "q" key is
released (KeyUP), TextBox1 should go away.
TextBox1 can be generated in the code under the KeyDown sub, and
deleted after KeyUp, I just don't know how to catch the keyboard key
actions with KeyDown and KeyUp.

Thanks,
Donny
 
L

Leith Ross

I am working on a sheet that has keyboard shortcuts. I want to use
keyboard buttons to control the worksheet. For example, if I press
the "q" key down, I want TextBox1 to appear. When the "q" key is
released (KeyUP), TextBox1 should go away.
TextBox1 can be generated in the code under the KeyDown sub, and
deleted after KeyUp, I just don't know how to catch the keyboard key
actions with KeyDown and KeyUp.

Thanks,
Donny

Hello Donny,

You can catch the KeyUp and KeyDown events on a VBA UserForm. There
are no equivalent events for an Excel Worksheet. Although a short cut
key can be assign directly to macro, this doesn't mean keyboard events
are also associated with the same macro automatically. Up and down
movement of Worksheet keystrokes can only be monitored by using
advanced API code techniques.

Sincerely,
Leith Ross
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top