Name

KeyPressEventArgs

Synopsis

Similar to the KeyEventArgs, this class encapsulates the data for the Control.KeyPress event.

You can simply retrieve the KeyChar corresponding to the key that was pressed. For example, pressing Shift-H would provide H, whereas pressing H would return h (of course, the Caps Lock key would change this).


public class KeyPressEventArgs : EventArgs {

// Public Constructors

   public KeyPressEventArgs(char keyChar);

// Public Instance Properties

   public bool Handled{set; get; }

   public char KeyChar{get; }

}

Hierarchy

System.Object System.EventArgs KeyPressEventArgs

Passed To

Control.OnKeyPress(), KeyPressEventHandler.{BeginInvoke(), Invoke()}, UpDownBase.OnTextBoxKeyPress()

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.