Pressing Escape Key only fires KeyUp Event, not KeyDown

Started by bhughes89, April 27, 2018, 08:23:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bhughes89

Hey guys,

For one of my projects I want to catch when the user presses the Escape key. I am looking to do some stuff before the actions of the ESC key are carried out, so I want to catch the KeyDown event. However, as far as I can tell pressing ESC only fires the KeyUp event in Visio.

From the research I did on Google, it sounds like this is normal if your document or userform has a command button with it's Cancel property set to true. I created a completely blank document, added the example KeyboardListener code from MSDN, and tried to catch the KeyDown event but without success.


Is it normal in Visio that pressing the Escape key (ESC) only invokes the KeyUp event, but not the KeyDown event?
Maybe I might have more success using the Keyboard Events object to catch the KeyDown event for the ESC key?
Does anyone know how to use the Keyboard Events object?


Attached are a couple of example documents that display keystrokes in different ways:

  • KeyboardListenerExample requires that you open the VBA Editor (alt+F11), open the Immediate Window (ctrl+G), then run the ToggleListen subroutine. Keystrokes will be displayed in the Immediate Window.
  • KeyboardListenerExample2 only requires that you double-click the console on the document page to start/stop listening, and keystrokes will be displayed on the page (though it is a bit slower than the first example doc).



Thanks in advance for your help!

bhughes89

Attached are pre-2010 versions of my example docs, for those that might need it.