Keyboard Events

There are three key events:

Thus the sequence of events is: KeyDOwn, KeyPress, KeyUp.

In the Designer file, we need a line to attach the handler to the event:

this.KeyDown += 
        new System.Windows.Forms.KeyEventHandler(this.KeyDemo_KeyDown);


KeyEventArgs class

This is found in the System.Windows.Forms namespace and has various properties, some of which are:


KeyPressEventsArgs

This has properties. The most useful is:

char KeyChar

which gives the ASCII character produced by the key or keys pressed.