RichTextBox e
-
Hy I have a RichTextBox. When I press any alphabetic key on RichTextBox_KeyDown the e.KeyValue have the ascci code for the bigger letter. I press "q" and the e.KeyValue have the ascci code for "Q". How can I detect what key I pressed? thanks
:confused:You've already identified what key you've pressed. Do you mean how do you work out what character it was? If so, just cast it to a string.
Deja View - the feeling that you've seen this post before.
-
:confused:You've already identified what key you've pressed. Do you mean how do you work out what character it was? If so, just cast it to a string.
Deja View - the feeling that you've seen this post before.
-
Hy I have a RichTextBox. When I press any alphabetic key on RichTextBox_KeyDown the e.KeyValue have the ascci code for the bigger letter. I press "q" and the e.KeyValue have the ascci code for "Q". How can I detect what key I pressed? thanks
e.Keycode
#region signature my articles #endregion
-
e.Keycode
#region signature my articles #endregion
-
Hy I have a RichTextBox. When I press any alphabetic key on RichTextBox_KeyDown the e.KeyValue have the ascci code for the bigger letter. I press "q" and the e.KeyValue have the ascci code for "Q". How can I detect what key I pressed? thanks
Hi, KeyDown/KeyUp events offer a KeyEventArgs with amongst others these key information properties: · Keys KeyCode: the keyboard code · Keys KeyData: the key data (i.e. the key that was pressed, combined with modifier flags that indicate which combination of CTRL, SHIFT, and ALT keys was pressed at the same time.) · int KeyValue: the integer representation of the KeyCode property KeyPress events offer a KeyPressEventArgs with amongst others these key information properties: · char KeyChar: the character (with correct casing) The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events. The typical use would be to process KeyDown to handle special keys (such as Enter, Backspace, and CTRL/X combinations), and to process KeyPress to consume regular keys (as in adding characters to text) :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google
-
You have only one key on the keyboard so that's why you are getting the same value. You can check for caps lock like this: Control.IsKeyLocked(Keys.CapsLock) and extract information about shift button from e.Keydata. Based on these two pieces of information you will be able to determine whether 'q' was typed or 'Q'
#region signature my articles #endregion