DeepKey Keyboard Library ======================== File: DeepKey - Update: 0.10 Author: J.G.Harston - Date: 07-Jun-2012 draft documentation Acknowledge: Gazza (Gareth Lock) DEFFNdeep_inkey(time%) ===================== If time% is negative, returns the keypressed state, as with INKEY. If time% is zero or positive, waits a maximum of time% centiseconds and returns -1 if no key pressed. DEFFNdeep_get ============ Waits forever until a key is pressed, and then returns a deep keypress value as with FNdeep_inkey(). Return values ============= Returns -1 if no key pressed, otherwise returns a 'deep' keypress combining the returned character, the physical keypress and the state of the modifier keys. If function and editing keys have not been redefined with *FX4,2 and *FX221,2-*FX228,2 then they return a 9-bit value &180-&1FF to distinguish them from top-bit-set characters. b0-b8 : character code (b8=1 if function/editing key) b9 : reserved b10 : RightAlt b11 : RightCtrl b12 : RightShift b13 : LeftAlt b14 : LeftCtrl b15 : LeftShift b16 : Alt pending b17 : Scroll Lock b18 : NumLock b19 : Shift b20 : Caps Lock b21 : reserved b22 : Ctrl b23 : Shift Lock b24-b31: physical key pressed Function/Editing Character Codes ================================ +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |18x| F0| F1| F2| F3| F4| F5| F6| F7| F8| F9| F10| F11 | F12| Ins| | | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |19x|sF1|sF1|sF2|sF3|sF4|sF5|sF6|sF7|sF8|sF9|sF10|sF11 |sF12|sIns| | | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |1Ax|cF0|cF1|cF2|cF3|cF4|cF5|cF6|cF7|cF8|cF9|cF10|cF11 |cF12|cIns| | | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |1Bx|aF0|aF1|aF2|aF3|aF4|aF5|aF6|aF7|aF8|aF9|aF10|aF11 |aF12|aIns| | | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |1Cx| | | | | | | | | | | | Copy| <-| ->| Dn | Up | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |1Dx| | | | | | | | | | | |sCopy| s<-| s->|sDn |sUp | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |1Ex| | | | | | | | | | | |cCopy| c<-| c->|cDn |cUp | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ |1Fx| | | | | | | | | | | |aCopy| a<-| a->|aDn |aUp | +---+---+---+---+---+---+---+---+---+---+---+----+-----+----+----+----+----+ s=Shift+key, c=Ctrl+key, a+key=Shift+Ctrl It can be seen from this table that bit5 and bit4 hold the state of Shift and Control keys. Physical Key Codes ================== Technical Notes =============== The library functions read the key pressed and then immediately read the physical keypress and the state of the modifier keys. As there is a small, but finite, time between read the keypress and reading the state of the modifier keys there is a small chance that the modifier key will be ignored. This will happen if keys are entered into the keyboard buffer faster than the program reads them, as only keypresses are buffered, not the state of the modifier keys. See also ======== Console library in http://mdfs.net/Apps/Emulators/Tube/cZ80Tube. Version History =============== 0.10 07-Jun-2012 Initial version. Disclaimer ========== The DeepKey library is provided "as-is" and is Copyright (C) J.G.Harston. No responsibility can or will be taken for any loss, damage, etc, whatsoever through its use. The DeepKey library may be freely redistributed and used in any BBC BASIC program. Please acknowledge its use in any documentation.