TransWikia.com

SendKeys.send is sending more than one character

Stack Overflow Asked by Onur Külekci on November 20, 2021

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?

One Answer

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;
        }
     }
    

Answered by Code Name Jack on November 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP