#PSTip Finding keyboard keys

A previous article in PowerShell Magazine describes how to find keyboard shortcuts in the PowerShell ISE. In this tip we will look at how we can find a key we do not know. The Go To Match keyboard shortcut in the ISE is Ctrl + Oem6. In my case I’m using a Dell laptop, and I have no clue where the Oem6 keyboard key is.

As a workaround, we can assign Go To Match a custom key combination in a PowerShell ISE Add-on menu item:

$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('GoToMatch',{$psise.CurrentFile.Editor.GoToMatch()},'Alt+X')

But if we really want to locate a keyboard key, we can use the Console.ReadKey method and simply start pressing buttons:

while($true){[Console]::ReadKey($true)}

In my case, Oem6 turned out to be the Norwegian letter å. To verify I tried Ctrl + å in the PowerShell ISE to find a matching bracket, which did work as expected.

comments powered by Disqus