I need some help with thread and key pressed

Hello

Here's my problem:
I have a GUI-program with to buttons, start and stop. When you press start the program shall begin and stop ends it. You don't see the program cause it's running in the background. What shall happen when you press 'start' I would like to have a listener on my keyboard, and when there is typed in a code followed with F1-F4 it shall but that code in a String and do different things when pressed F1-F4....

Eks. I'll type '2421fdsf' on my keybord followed with [F1], than it shall write "hey world + code", and when [F2] is pressed it shall write "End + code"... It's just an example, in the real thing it should do more advanced things. But for now, I have to get thiiis working.

CAn anyone please help me
I'm using Visual Studio 2005, and are new to it.




Answer this question

I need some help with thread and key pressed

  • Alberto Arias

    Hey:)

    Sorry for the late answer, i've been on an easter holiday :)

    I figure it out. I was just to write:

    private void textBox_logg(object sender, KeyEventArgs e)
    if
    (e.KeyCode == Keys.F1)
    {
    // What ever you like it to do
    }



  • Anando_Paul_edc3ee

    so plz if you asked a question and found the answer later post it and mark it as answr

    best regards



  • Hugh Qu - MSFT

    Thank you Labomba and Shakalama for the follow up.

    regards,
    Bhanu.



  • Bob Kilbertus

    Hi,

    Where should it write "hey world + code" and "End + code" when user types something + F1-F4

    Thank you,
    Bhanu.



  • I need some help with thread and key pressed