If I know that a certain key has been pressed (eg Key.D3), and that the Shift key is also down (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)), how can I find out what character that refers to (eg, # on US keyboard, UK pound sign on UK keyboard, etc)?
Put another way, how can I find out, programatically, that Shift + 3 produces # (it wouldn’t on a non-US keyboard).
If you want to determine what character you will get from a given key with given modifiers, you should use the
user32 ToAsciifunction. OrToAsciiExif you want to use a keyboard layout other then the current one.You can now use it like this:
If you need more than one modifier, just
orthem.Keys.ShiftKey | Keys.AltKey