26

A friend was having trouble figuring out how to assign "Ctrl + +" as a shortcut key to a ToolStripMenuItem. I pointed out that the Keys.OemPlus key would work and the display string for the shortcut needed to be set, but the Keys enumeration mystifies me.

What's the deal with these "OEM" keys? I've done a little searching and it seems like it's because the keys are only supported in Win2k or later, but that seems ridiculous as I'm certain people have been using the plus key decades before Win2k. Why's there no "OemEquals"? Are there other keys that are completely absent from the Keys enumeration?

I'm mostly looking for an answer to why these special-named values exist, but I'd love to hear discussion about the other questions. Is it safe to assume that since the plus sign is on top of the equals sign on my keyboard that using Keys.OemPlus and checking the Shift modifier key is an OK to tell if Ctrl + = was clicked? Are there other keys that were omitted?

Note this is not a WPF question, though the System.Windows.Forms.Keys and System.Windows.Input.Key enumerations look identical (though Key is named incorrectly according to the Framework Design Guidelines ;))

0

2 Answers 2

34

They were introduced with the Windows API, they are not specific to WPF.

First, these are KEY codes, not character codes: they identify a key on your keyboard, not a character - e.g. the 'A' character is usually generated by pressing the A key while holding down a SHIFT key or having CAPS LOCK active.

The OEM keys are the keys that vary with local keyboards. Where the US keyboard has brackets and braces, german keyboards have umlauts.

They are called "OEM" because the Original Equipment Manufacturer (of the keyboard) was responsible for defining their functionality.

3
  • 2
    I believe the various media keys are OEM keys as well. Commented Jan 1, 2010 at 19:48
  • So for instance for Oem3 which is the back tick ``` key is that saying it isn't common on non US keyboards so it doesn't get to be Key.BackTick but as long as I'm on a US layout it should always represent the back-tick key? Commented Oct 25, 2017 at 1:17
  • @Simon_Weaver Yes, correct. Switching layout can have a different key and symbols represent Oem3. Furthermore, the software can read what the unshifted symbol is on the key and display it as "Ctrl + ..." so the use knows what key it represents on their keyboard
    – Liggliluff
    Commented Aug 5, 2019 at 0:14
-5

OEM means "Original Equipment Manufacturer" (or something relatively close to that). I think it's an attempt on WPF's part to be somewhat platform neutral. That's just an opinion though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.