Form.KeyUp
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class FormMouseKeyEvent : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public FormMouseKeyEvent()
{
this.KeyUp += new KeyEventHandler(OnKeyUp);
InitializeComponent();
CenterToScreen();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}
[STAThread]
static void Main()
{
Application.Run(new FormMouseKeyEvent());
}
public void OnKeyUp(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyCode.ToString(), "Key Pressed!");
}
}
Related examples in the same category