What does IAccessible::get_accKeyboardShortcut() return?

If you said, “A Control’s Keyboard Shortcut”, that’s incorrect!


I get asked this question from time to time, so I’m going to share the answer here.


Let’s review a Keyboard Shortcut versus a Mnemonic.  A mnemonic is a control’s underlined letter or its access key.  A keyboard shortcut is a combination of keystrokes to perform some sort of action, like Ctrl-P to print or Ctrl-S to save.


The IAccessible::get_accKeyboardShortcut contains a control’s mnemonic (that is, its underlined letter) and not its actual keyboard shortcut for interacting with the control.  What I mean is that the keyboard shortcut for interacting with a button is Enter, but IAccessible::get_accKeyboardShortcut does not return “Enter”.  Instead, ::get_accKeyboardShortcut returns the mnemonic or access key for these controls, like ‘B’ for Browse.  Let’s take a look at a combo box.  Although the keyboard shortcut to interact with a combo box’s drop down is Alt+Down Arrow, the ::get_accKeyboardShortcut method returns its mnemonic like “Alt-O” for “Open:”


If the control doesn’t have an underlined letter or mnemonic, it doesn’t have a MSAA keyboard shortcut.


My fellow testers out there are probably thinking, “what happens if a control has both a keyboard shortcut and a mnemonic?”  The Mnemonic is returned for the ::get_accKeyboardShortcut.


For a real world example, try using AccExplorer32 v2.0 at the Start – Run dialog’s buttons and combo box.  For a real world example of using both a keyboard shortcut and a mnemonic, point Inspect32 (AccExplorer32 would also work, but it might try to capture all objects in the menu bar, and that takes a while) at the File – Save menu item in Microsoft Office Outlook 2003.  The save menu item has both an underlined S and also a Ctrl-S, and Inspect reports S for its keyboard shortcut.  If you’re thinking “why didn’t it return Alt-S?”, remember, you’ve already pressed Alt to reach the menus, so pressing S will cause the document to Save.


Hope this helps!

Comments (3)

  1. Kevin Dente says:

    Which begs the question, why was it not called get_accKeyboardMnemonic? 😉

    There seems to be general looseness around the terms shortcut and mnemonic which can definitely be confusing.