problem with keypress function
-
Hi What i need to do is to get keyboard letters and "letter combinations" which is the core of my problem for ex: when i press alt + f4 i wnat to see alt f4 in the label i have the code snippet
protected override void OnKeyDown(KeyEventArgs keyEvent)
{label1.Text = ""; label1.Text=keyEvent.KeyCode.ToString(); //while(?) i wanted to write a while loop for while the key is still pressed(down) //label1.Text=keyEvent.KeyCode.ToString()+"+"+label1.Text; }
Can anyone show me a way to do it please? Thanks...
-
Hi What i need to do is to get keyboard letters and "letter combinations" which is the core of my problem for ex: when i press alt + f4 i wnat to see alt f4 in the label i have the code snippet
protected override void OnKeyDown(KeyEventArgs keyEvent)
{label1.Text = ""; label1.Text=keyEvent.KeyCode.ToString(); //while(?) i wanted to write a while loop for while the key is still pressed(down) //label1.Text=keyEvent.KeyCode.ToString()+"+"+label1.Text; }
Can anyone show me a way to do it please? Thanks...
-
Hi What i need to do is to get keyboard letters and "letter combinations" which is the core of my problem for ex: when i press alt + f4 i wnat to see alt f4 in the label i have the code snippet
protected override void OnKeyDown(KeyEventArgs keyEvent)
{label1.Text = ""; label1.Text=keyEvent.KeyCode.ToString(); //while(?) i wanted to write a while loop for while the key is still pressed(down) //label1.Text=keyEvent.KeyCode.ToString()+"+"+label1.Text; }
Can anyone show me a way to do it please? Thanks...
forget the loop, loops seldom belong in an event handler. Create one method that is used for both KeyDown and KeyUp events. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in
-
Hi What i need to do is to get keyboard letters and "letter combinations" which is the core of my problem for ex: when i press alt + f4 i wnat to see alt f4 in the label i have the code snippet
protected override void OnKeyDown(KeyEventArgs keyEvent)
{label1.Text = ""; label1.Text=keyEvent.KeyCode.ToString(); //while(?) i wanted to write a while loop for while the key is still pressed(down) //label1.Text=keyEvent.KeyCode.ToString()+"+"+label1.Text; }
Can anyone show me a way to do it please? Thanks...
Check the value of keyEvent.Alt, it will be true if the alt key is held down.
-
Hi What i need to do is to get keyboard letters and "letter combinations" which is the core of my problem for ex: when i press alt + f4 i wnat to see alt f4 in the label i have the code snippet
protected override void OnKeyDown(KeyEventArgs keyEvent)
{label1.Text = ""; label1.Text=keyEvent.KeyCode.ToString(); //while(?) i wanted to write a while loop for while the key is still pressed(down) //label1.Text=keyEvent.KeyCode.ToString()+"+"+label1.Text; }
Can anyone show me a way to do it please? Thanks...
Hi, You can override the ProcessCmdKey() function in Control class like this : protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.Alt | Keys.F4)) { //Your Code } return base.ProcessCmdKey(ref msg, keyData); } Hope this helps, ramz_g :-)