private void Form1_Load(object sender, EventArgs e) { this.KeyPreview = true; this.PreviewKeyDown += new PreviewKeyDownEventHandler(Form1_PreviewKeyDown); textBox1.PreviewKeyDown += new PreviewKeyDownEventHandler(Form1_PreviewKeyDown); } private void Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { try { MessageBox.Show(e.KeyCode.ToString() + " key pressed on " + sender.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyData.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)