-2

sorry for my bad english.

I am writing a keyboard application for the touchscreen. but,

for example, when I press the A key, sometimes it's writes 5 times A key . I am using basically button click event.

private void button42_Click(object sender, EventArgs e)
    {
        SendKeys.Send("A");
        Thread.Sleep(100);
    }

there is no problem with the mouse_click event. just touch

how can i do it?

1 Answers1

-2

1.Try handling it in a mouse_up or touch_up event instead of using a delay here. Actual implementation and events will depend on you framework.

mouse_up /touch_up will make sure that you even only fires when touch is released.

To add repetition on touch and hold, you may have to add additional logic however.

  1. Try declaring a field to toggle the value of event fired.

     private bool handling=false;
     private void button42_Click(object sender, EventArgs e)
     {
         if(!handling)
         {
             handling=true;
             SendKeys.Send("A");
             Task.Delay(100).Wait();
             handling=false;
        }
     }
    
Code Name Jack
  • 2,856
  • 24
  • 40