Arduino uno connect with computer keypad

I want to turn on/off motor by arduino uno. But it should be by computer key press. I wrote code. But its working with serial monitor. Anyone can fix my code for without serial monitor?
I attached code file.

abc.ino (1.47 KB)

abc.ino (1.47 KB)

Anyone can fix my code for without serial monitor?

If it works with the Serial monitor it will work with any program that can send serial data from the PC. Some terminal emulators allow characters to be sent as they are typed and do not require you to press return. Is that what you had in mind ?

DinuR: Anyone can fix my code for without serial monitor?

If you mean that you would like your PC keyboard to control an Arduino without any program running on the PC then that is not possible.

As @UKHeliBob has said you are not confined to using the Arduino Serial Monitor, but you will need some program running on the PC to detect the keypress and send a message to the Arduino - even if the message is only the character for the key that has been pressed.

...R