Mapping keyboard shortcuts (like ESC to close a work item)

If you are a regular user of Visual Studio, you may already know this. But I didn't for a while, and am now taking advantage of it.

VS allows you to map keys to any number of commands, including Team Foundation Server commands.

To do this, Select "Tools | Options", then expand "Environment" and select Keyboard.

If you want to map the "ESC" key to close a work item, then first enter "CloseDocumentWindow" in "Show commands containing". This will filter all the commands to those containing that text. (There will only be one).

You will see that "Control-F4" is the currently assigned key to close a document window. I really don't like that, I like ESC.

Then put the cursor in the "Press shortcut keys" text box. Now press the ESC key. You will see ESC appear. Now press the Assign button, and that key is now mapped.

You will see a listbox: "Use new shortcut in:", which probably defaults to "Global". This is the context of the new keyboard shortcut. "Global" means the key will work no matter where you are at (code editor, debugger) in VS.

If you want to map a key within the context of a Work Item Tracking window, there are three contexts to select from that "Use new shortcut in:" listbox:

* Work Item Editor

* Work Item Query View

* Work Item Results View

If you select those contexts (instead of Global), then the mapped key will only be effective within that context. For example, you may want ESC to only close "Work Item Editor" windows.

Anyway, I like it and it works well for me. Let me know what you think.