Generally you would have some sort of simple serial connection between your computer and the mcu. This typically is a connection between the UART on your mcu, and the computer; this can take a lot of forms, hardware-wise.
The way I've done this is using existing code, e.g. the WebbotLib library, which provides most of the code for reading bytes (these include individual letters such as typed on the keyboard) from the hardware.
A bit of pseudocode for what the code that I have to write for this looks like:
char key_press = serial.getByte();
if(key_press == 'a'){
led_on();
}
else if (key_press == 'b'){
led_off();
}
To send single letters like in the above, from your computer, one typically uses a terminal program like Hyperterminal, Putty, X-Ctu, realterm, etc. For more advanced stuff, one might write a program that sends specific bytes to a program, but don't worry about that for now....
You'll have to tell us more about your hardware setup for us to give you more information.