Short: Check if keys are pressed (for scripts) Author: zodiac@darkness.gun.de (Ralph Seichter) Uploader: zodiac darkness gun de Type: util/batch Architecture: m68k-amigaos This tool checks if at least one key of a given list of keys is pressed and delivers an appropriate return code, which can be processed in shell scripts to trigger any action you like. To give you an idea of what "KeyPressed" can do for you, imagine that you have three different startup-sequences around. Number 1 is the one for everyday use, the standard startup. Number 2 and 3 are optimized versions for special applications. When you want to execute number 2 or 3 on bootup, you could boot once without a startup-sequence, then copy the desired file over your standard startup (make sure to backup Number 1 first), and then reboot your Amiga. Does this sound inconvenient? It is. "KeyPressed" will help you out of your misery. Include the following lines somewhere at the beginning of your S:startup-sequence (your standard startup file) and copy "KeyPressed" to your C: directory or elsewehere in your command path. KeyPressed 64 IF WARN ; KeyPressed reports that the space bar (raw key code 64) ; was pressed. Execute alternate startup-sequence number 2. Execute S:startup-sequence.2 EndCLI >NIL: Quit ENDIF KeyPressed 96 97 99 IF WARN ; The control key (raw key code 99), the left shift key (96) ; or the right shift key (97) was pressed. Execute alternate ; startup-sequence number 3. Execute S:startup-sequence.3 EndCLI >NIL: Quit ENDIF As you can see, "KeyPressed" requires a list of decimal raw key codes. You can supply as many codes as you wish, but as there is only a fixed number of keys on a keyboard, there is a natural limit implied. :) "KeyPressed" will return the code 5 (RETURN_WARN) if at least one of the specified key was pressed, and otherwise 0 (RETURN_OK) is returned. Please Note that raw key codes are *DIFFERENT* from ASCII codes. Here is a list of selected codes common to all Amiga models: Key name Code Space bar 64 Enter (numeric keypad) 67 Return 68 F1 - F10 80 - 89 Help 95 For a complete list of the Amiga's raw key codes, please have a look at the ROM Kernel Reference Manual "Devices" (section "console.device").