Key press

  • Thread starter Thread starter Rado
  • Start date Start date
R

Rado

Hello.

In Event key_press I write
If e.KeyChar = Microsoft.VisualBasic.Chr(127) Then

Asci 127 is key DELET.

But it doesn't work, when I get other Ascii It's ok.

And When I press CTRL+BACKSPACE with ascii 127 it's ok. CTRL+BACKSPACE = DEL, but with del it doesn't work.

Can anybody write me where is problem?

Thanks.
 
Hi,

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Delete Then
MessageBox.Show("Delete pressed")
End If
End Sub

Ken
--------------
Hello.

In Event key_press I write
If e.KeyChar = Microsoft.VisualBasic.Chr(127) Then

Asci 127 is key DELET.

But it doesn't work, when I get other Ascii It's ok.

And When I press CTRL+BACKSPACE with ascii 127 it's ok. CTRL+BACKSPACE = DEL, but with del it doesn't work.

Can anybody write me where is problem?

Thanks.
 
Rado said:
In Event key_press I write
If e.KeyChar = Microsoft.VisualBasic.Chr(127) Then

Asci 127 is key DELET.

But it doesn't work, when I get other Ascii It's ok.

And When I press CTRL+BACKSPACE with ascii 127 it's ok.
CTRL+BACKSPACE = DEL, but with del it doesn't work.

Can anybody write me where is problem?

First, your keyboard (and it's driver) produces "virtual keycodes". Whenever
a key is held down or released, the keydown or keyup events are raised. In
the event handlers, e.keycode contains the virtual keycode. (Almost) all
keys create this message and event.

Second, some of the keys or a combination of them are translated to input
chars afterwards. Others don't, like the function keys. If you press delete,
no input char is created. Use the keydown event to handle the Delete key.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
* "Rado said:
In Event key_press I write

If e.KeyChar = Microsoft.VisualBasic.Chr(127) Then

Asci 127 is  key DELET.

But it doesn't work, when I get other Ascii It's ok.

And When I press CTRL+BACKSPACE with ascii 127 it's ok.  CTRL+BACKSPACE = DEL, but with del it doesn't work.

Compare 'e.KeyChar' to one of the 'Keys.*' constants.
 
Back
Top