Sunday 15 March 2015

c# - How to capture keystroke(s) pressed in certain time period for DataGridView keypress event? -


I have to catch the keystrokes pressed in a certain time period, for example 300 ms when I ' A and press ' B ' within 300ms, then I need the string " ab ". But if I press the key ' c ' after pressing 300 ms after ' b ' then I need " c ".

I need to quickly jump for the DataGridView's cell which starts with the quick pressed key (s).

I'm not completely sure that I understand your question, but I believe Is that if you press two keys, or if you press three keys, you want a way to execute a block code on the second block of code. Additionally, you want each key to be pressed within 300ms of each other. If I understand, then you should do this code:

  Private Systems Diagnostics Look at the port = new system Diagnostics Harbour (); Private string _ keyed; Public string key pressed {get {return_keys; } Set {Watch.Stop (); If (see Apple Milliseconds & lt; 300) _Keyspressed + = Value; Else _Keyspressed = Value; Watch.Reset (); Watch.Start (); }} Private Zero keyUpEvent (Object Sender, KeyEventArgs e) {Keyspressed = e.KeyCode.ToString (); If pressed (key == "AB") lblEventMessage.Text = "you have pressed ABC"; Else if pressed (key == "ABC") lblEventMessage.Text = "You have pressed ABC"; Else lblEventMessage.Text = "C-C-C-Combo BREAKER !!!"; }   

This code identifies a label, lblEventMessage, and something to trigger a KeyUp event (I went with a text box).

No comments:

Post a Comment