#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 on the R&D Team at Crayon, Norway. He mainly works with automation, and has a strong passion for PowerShell. Products and services he works with includes Microsoft infrastructure products such as Windows Server, System Center and Microsoft Azure. 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-founder of the Norwegian Microsoft Technology User Group (MTUG), which is an association of local MTUG user groups in Norway. He is also co-organizing the MTUG Script Club which focuses mainly on PowerShell. You can follow him on Twitter @JanEgilRing.

Related Posts

%d bloggers like this: