-2

I want to make background code that checks if someone hit "H","D", or other letters. Like This,(I mean a background code that is checking this.)

if(e.KeyCode == Keys.U)
{
code;
}
CoderModer
  • 11
  • 2
  • If you want it on background as in a keylogger, have a look at this: http://null-byte.wonderhowto.com/how-to/create-simple-hidden-console-keylogger-c-sharp-0132757/. – Lucas Corsaletti Jan 14 '17 at 17:00

1 Answers1

1

In WinForms you can override onKeyDown() like so:

protected override void onKeyDown(KeyEventArgs e)
{
    if (e.KeyCode == Keys.YourKey)
    {
        // Do something
    }
}

Where you substitute YourKey with desired key from Keyboard. (You can use intellisense to see all available options)

Kamil Solecki
  • 1,106
  • 20
  • 34