2
4

1 に答える 1

2
  1. Pressing Ctrl, Alt, or Shift individually caused Control, Alt, and Shift to return true in my KeyDown event handler. Pressing each one of those keys individually resulted in false being returned in my KeyUp event handler. Are you sure you're not handling the KeyUp event?

  2. As @sean woodward said, Windows Key should map to either Keys.LWin or Keys.RWin

  3. The KeyPress event is only raised when one of the character keys is pressed and will return the character that results from the pressed key or combination of pressed keys. Ctrl+Shift+B is not a character so you can't use KeyChar alone to get that information. Try using the KeyDown or KeyUp event and looking at the Modifiers property to get a comma delimited string of which modifier keys are being pressed. If order matters you'll need to track that as Modifiers always returns the keys in the same order, i.e. Shift, Control, Alt even if that's not how they were pressed.

Here is the code I used, you can try playing around with it:


KeyDown += (o, ea) =>
{
    System.Diagnostics.Debug.WriteLine("KeyDown => CODE: " + ea.KeyCode +
        ", DATA: " + ea.KeyData +
        ", VALUE: " + ea.KeyValue +
        ", MODIFIERS: " + ea.Modifiers +
        ", CONTROL: " + ea.Control +
        ", ALT: " + ea.Alt +
        ", SHIFT: " + ea.Shift);

};

KeyUp += (o, ea) =>
{
    System.Diagnostics.Debug.WriteLine("KeyUp => CODE: " + ea.KeyCode +
        ", DATA: " + ea.KeyData +
        ", VALUE: " + ea.KeyValue +
        ", MODIFIERS: " + ea.Modifiers +
        ", CONTROL: " + ea.Control +
        ", ALT: " + ea.Alt +
        ", SHIFT: " + ea.Shift);
};

KeyPress += (o, ea) => 
{
    System.Diagnostics.Debug.WriteLine("KeyPress => CHAR: " + ea.KeyChar);
};
于 2013-02-17T06:07:49.617 に答える