Search code examples
c#sendkeys

C# SendKeys.Send


I am running on an issue using C# SendKeys.Send method. I am trying to replace keyboard keys with other keys, for example when I press "a" in keyboard I want that key to be "s" for example, when I am doing this in my code:

if ((Keys)keyCode== Keys.A)
{                    
    SendKeys.Send("s");                    

}

Right now I get only "sa" character printed in my notepad, but instead of printing "sa" I need to get only "s" character in this case because when I press "a" on my keyboard, "a" must be replaced with "s".

I tried removing the last character by adding this line:

SendKeys.Send("{BS}");

But all I got is "s" character removed and "a" character was there.

How can I prevent this from happening?


Solution

  • I solved this problem by registering global hot keys. Thank you. This was the resourse that I used to solve my problem.