EKEY
return values for some keyboard events[ ] conforms to ANS Forth. iForth Gforth VFX Forth for Windows/DOS/Linux MPE Forth cross compilers PFE (Guido Draheim) [ ] already implements the proposal in full since release [ ]: iForth 3.0 [ ] implements the proposal in full in a development version: [ ] will implement the proposal in full in release [ ]. Gforth 0.7 PFE 33.67 [ ] will implement the proposal in full in some future release. VFX Forth for Windows/DOS/Linux There are no plans to implement the proposal in full in [ ]. 4th V3.5a (no EKEY support) [ ] will never implement the proposal in full: MPE Forth cross compilers
[ ] I have used (parts of) this proposal in my programs: Robert Epprecht [ ] I would use (parts of) this proposal in my programs if the systems I am interested in implemented it: David N. Williams Graham Smith [ ] I would use (parts of) this proposal in my programs if this proposal was in the Forth standard: Charles Melice David N. Williams Graham Smith [ ] I would not use (parts of) this proposal in my programs. Hans Bezemer (does not use EKEY)
EKEY>FKEY ( u1 -- u2 f ) facility ext If the keyboard event u1 corresponds to a keypress in the implementation-defined special key set, return that key's id u2 and true. Otherwise return u1 and false.The following words produce the same values that
EKEY EKEY>FKEY
may produce when the user presses the
corresponding key. Note that, even if this extension is present, the
keyboard may lack some of the keys, or the system the capability to
report them, so programs should be written such that they also work
(although less conveniently or with less functionality) if these key
numbers cannot be produced.
K-LEFT ( -- u ) facility ext The "cursor left" key K-RIGHT ( -- u ) facility ext The "cursor right" key K-UP ( -- u ) facility ext The "cursor up" key K-DOWN ( -- u ) facility ext The "cursor down" key K-HOME ( -- u ) facility ext The "home" or "Pos1" key K-END ( -- u ) facility ext The "End" key K-PRIOR ( -- u ) facility ext The "PgUp" or "Prior" key K-NEXT ( -- u ) facility ext The "PgDn" or "Next" key K-INSERT ( -- u ) facility ext The "Insert" key K-DELETE ( -- u ) facility ext The "Delete" key K-F1 ( -- u ) facility ext The "F1" key K-F2 ( -- u ) facility ext The "F2" key K-F3 ( -- u ) facility ext The "F3" key K-F4 ( -- u ) facility ext The "F4" key K-F5 ( -- u ) facility ext The "F5" key K-F6 ( -- u ) facility ext The "F6" key K-F7 ( -- u ) facility ext The "F7" key K-F8 ( -- u ) facility ext The "F8" key K-F9 ( -- u ) facility ext The "F9" key K-F10 ( -- u ) facility ext The "F10" key K-F11 ( -- u ) facility ext The "F11" key K-F12 ( -- u ) facility ext The "F12" keyThe following words produce a mask, that you can OR with the key values above to produce a value that
EKEY EKEY>FKEY
may produce when the user presses the corresponding key combination.
K-SHIFT-MASK ( -- u ) facility ext Mask for the shift key K-CTRL-MASK ( -- u ) facility ext Mask for the ctrl key K-ALT-MASK ( -- u ) facility ext Mask for the alt key
... ekey ekey>fkey if case k-up of ... endof k-f1 of ... endof k-left k-shift-mask or k-ctrl-mask or of ... endof ... endcase else ... then
: EKEY>FKEY ( u1 -- u2 flag ) dup ekey>char nip 0= ;
K1
...K10
for the
function/keypad keys; they also contain
S-K1
...S-K10
for shifted function/keypad
keys, but they don't work as widely. Moreover, Gforth (but not PFE)
also has K-INSERT K-DELETE K11 K12 S-K11 S-K12
. Should
any of these words be added to this proposal? After the first RfD,
several people were in favour of adding such words and nobody spoke
out against, so I added the words after K-NEXT. If you don't like
such words in general, or would like them, but differently, please
speak up now.
EKEY
, and therefore unportable, so I don't provide a
reference implementation. However, you can look at the Gforth
implementation of EKEY and many of these words (based on ANSI
terminal escape sequences).
Win32Forth provides; k_home k_up k_pgup k_left k_right k_end k_down k_pgdn k_insert k_delete k_scroll plus k_1 through k_12 for function keys. +k_control +k_alt +k_shift provide a mask when these keys are depressed with any of the above.
Marcel Hendrix writes <13073534183561@frunobulax.edu> that iForth implements this functionality, but with different key names.
Mitch Bradley reports that the current proposal cannot be implemented in a useful way on the current Quartus Forth even though the platform has some arrow buttons. Quartus Forth implements an EKEY that just returns an event type (and requires the use of another word to get more information).
Charles Melice and Alex McDonald would prefer K-F1 etc. for function keys, and masks for shifted keys etc.
Charles Melice would also like to see some events defined for mouse events (<44734824$0$20278$ba620e4c@news.skynet.be> ff.). There was some discussion on how that should be done; however, it will not be done in this proposal.
Sam Falvo also has some interesting suggestions in this area <1149102251.881940.142140@j55g2000cwa.googlegroups.com> that might be interesting for a future RfD.
Charles Melice also proposed <447c27b5$0$23533$ba620e4c@news.skynet.be> having a word EKEY>FKEY and standardizing the numeric FKEY values to make it easier to save, exchange, and replay these keys between systems.
Robert Epprecht uses these words and would like to have them available in different Forth implementations. Also, he would like to see the words for the function keys.
Note that you can be both a system implementor and a programmer, so you can submit both kinds of ballots.
[ ] conforms to ANS Forth. [ ] already implements the proposal in full since release [ ]. [ ] implements the proposal in full in a development version. [ ] will implement the proposal in full in release [ ]. [ ] will implement the proposal in full in some future release. There are no plans to implement the proposal in full in [ ]. [ ] will never implement the proposal in full.If you want to provide information on partial implementation, please do so informally, and I will aggregate this information in some way.
[ ] I have used (parts of) this proposal in my programs. [ ] I would use (parts of) this proposal in my programs if the systems I am interested in implemented it. [ ] I would use (parts of) this proposal in my programs if this proposal was in the Forth standard. [ ] I would not use (parts of) this proposal in my programs.If you feel that there is closely related functionality missing from the proposal (especially if you have used that in your programs), make an informal comment, and I will collect these, too. Note that the best time to voice such issues is the RfD stage.