#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)}

readkey

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.

About the author: Jan Egil Ring

Jan Egil works as a Lead Architect at Crayon, Norway. He mainly works with automation, and has a strong passion for PowerShell. He has been working with Microsoft infrastructure products such as Windows Server & System Center since the early 2000s. In the recent years the focus has been more and more related to cloud technologies in Microsoft Azure and hybrid environments. He is a multiple-year recipient of Microsoft Most Valuable Professional Award for his contributions in the Windows PowerShell and Cloud & Datacenter Management technical communities. He speaks regularly at user groups and conferences, such as Nordic Infrastructure Conference (NIC), PowerShell Conference Europe and PowerShell Summit. He is a co-organizer of Azure User Group Norway as well as the MTUG (Microsoft Technology User Group) Script Club which focuses mainly on PowerShell. You can follow him on Twitter @JanEgilRing.

Related Posts