home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 11
/
AACD11.ISO
/
System
/
C
/
KeyPressed.doc
< prev
next >
Wrap
Text File
|
1995-08-30
|
3KB
|
84 lines
========================================================
KeyPressed 36.1 (30.8.95) Copyright (c) Ralph Seichter
========================================================
DESCRIPTION
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").
COPYRIGHT NOTICE
"KeyPressed" is Copyright (c) Ralph Seichter, all rights reserved. You
have permission to use this tool freely and make as many copies as you
wish. You *MUST NOT* charge other people for supplying them with copies of
"KeyPressed". Adding any files to or removing files from the distribution
archive is *PROHIBITED*.
DISCLAIMER
THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, STATUTORY OR OTHERWISE, INCLUDING WITHOUT LIMITATION
ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE USE, RESULTS, AND
PERFORMANCE OF THIS MATERIAL IS ASSUMED BY YOU AND IF THE PRODUCT SHOULD
PROVE TO BE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY
SERVICING, REPAIR, OR OTHER REMEDIATION.