batch file that detects keystrokes. how?

Posted by daniel11 on Stack Overflow See other posts from Stack Overflow or by daniel11
Published on 2010-12-02T21:34:03Z Indexed on 2012/11/01 17:01 UTC
Read the original article Hit count: 461

im designing a collection of video games for the command line (such as deal or no deal, tic tac toe, racing, maze puzzle, connect four, wack a mole, etc.) however it would really make things easier for me if i could make it so that when the user makes a selection (such as what direction to move in the game) , that as soon as they press the arrow keys then it carries out the IF statements that follow. Instead of having to press enter after each selection. something like...

:one1
set /p direction1= :
IF %direction1%== {ARROW KEY LEFT} goto two2
IF %direction1%== {ARROW KEY RIGHT} goto three3
IF %direction1%== {ARROW KEY UP} goto four4
IF %direction1%== {ARROW KEY DOWN} goto five5
goto one1

Any Ideas?

© Stack Overflow or respective owner

Related posts about batch

Related posts about keyboard