How do you set the Keyboard key [ESC] as a global "GOTO

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
thr333
Posts: 16
Joined: 24 Aug 2009 10:24

How do you set the Keyboard key [ESC] as a global "GOTO

#1 Post by thr333 » 17 Dec 2009 06:06

How do you set the Keyboard key [ESC] as a global "GOTO" into the code of a batch file?

Why am I asking?
Let's say you have a simple DOS menu
which asks user to choose a number, then press [ENTER].
The instructions complete, then we see the classic "Pause" line before exiting:
Press any key to continue . . .

But...
I want to code the [ESC] key into the batch so that
if it is ever pressed at any time, we ALWAYS go back to the start menu.
ie. it will overide all, including the execution of "Pause".

This is similar to what you see when you are in the BIOS.

___________________________________

Here is an answer from someone at another site:

> assuming the keyboard input is held in the variable InputValue$ ,
> then the code would be something like this :

> IF InputValue$ = CHR$(27) THEN ..... ELSE

> action code after the THEN depends on how u have coded the program,
> u cud END or GOTO a line number , or break out of a loop and
> go back to the start , call a procedure , whatever ..

> u then need to clear the value still held in the InputValue$ variable > before the input process resumes .

> the ELSE just runs your program code if the value input is not = CHR$(27)


I am not a total batch noob, but this is entering unfamiliar territory for me.
I don't know how to interpret what he is saying into a practical test model;

If anybody here can offer any insights I can grasp, it would be highly appreciated.
Thanks.

Post Reply