M32:ifhitkey

From EDukeWiki
Jump to navigation Jump to search

ifhitkey <KEY_SC>

This command will branch if the key specified by the scancode has been activated, or take the 'else' branch otherwise.

While inside the block, the key status remains active. Once the branch block is exited, the key will be deactivated (some are unaffected, see below).

See also: ifholdkey

Usage:

  ifhitkey KEY_F
  {
     // do stuff if key active
  }
  else
  {
     // do stuff if key inactive
  }
  
  // key status is guaranteed deactivated after the block (with exceptions)

Scancodes

The following key scancodes are defined within Mapster32:

Defined Scancodes
Exposed Name Internal Name Hex Value Notes
KEY_1 KEYSC_1 0x02
KEY_2 KEYSC_2 0x03
KEY_3 KEYSC_3 0x04
KEY_4 KEYSC_4 0x05
KEY_5 KEYSC_5 0x06
KEY_6 KEYSC_6 0x07
KEY_7 KEYSC_7 0x08
KEY_8 KEYSC_8 0x09
KEY_9 KEYSC_9 0x0a
KEY_0 KEYSC_0 0x0b
KEY_A KEYSC_A 0x1e
KEY_B KEYSC_B 0x30
KEY_C KEYSC_C 0x2e
KEY_D KEYSC_D 0x20
KEY_E KEYSC_E 0x12
KEY_F KEYSC_F 0x21
KEY_G KEYSC_G 0x22
KEY_H KEYSC_H 0x23
KEY_I KEYSC_I 0x17
KEY_J KEYSC_J 0x24
KEY_K KEYSC_K 0x25
KEY_L KEYSC_L 0x26
KEY_M KEYSC_M 0x32
KEY_N KEYSC_N 0x31
KEY_O KEYSC_O 0x18
KEY_P KEYSC_P 0x19
KEY_Q KEYSC_Q 0x10
KEY_R KEYSC_R 0x13
KEY_S KEYSC_S 0x1f
KEY_T KEYSC_T 0x14
KEY_U KEYSC_U 0x16
KEY_V KEYSC_V 0x2f
KEY_W KEYSC_W 0x11
KEY_X KEYSC_X 0x2d
KEY_Y KEYSC_Y 0x15
KEY_Z KEYSC_Z 0x2c
KEY_SPACE KEYSC_SPACE 0x39
KEY_ENTER KEYSC_ENTER 0x1c
KEY_DASH KEYSC_DASH 0x0c
KEY_EQUAL KEYSC_EQUAL 0x0d
KEY_BS KEYSC_BS 0x0e Backspace Key
KEY_TAB KEYSC_TAB 0x0f
KEY_LBRACK KEYSC_LBRACK 0x1a
KEY_RBRACK KEYSC_RBRACK 0x1b
KEY_SEMI KEYSC_SEMI 0x27 Semi-Colon
KEY_QUOTE KEYSC_QUOTE 0x28
KEY_BQUOTE KEYSC_BQUOTE 0x29 Internal Alias: "KEYSC_TILDE".
KEY_SLASH KEYSC_SLASH 0x35
KEY_BSLASH KEYSC_BSLASH 0x2b
KEY_COMMA KEYSC_COMMA 0x33
KEY_PERIOD KEYSC_PERIOD 0x34
KEY_LALT KEYSC_LALT 0x38
KEY_RALT KEYSC_RALT 0xb8
KEY_LCTRL KEYSC_LCTRL 0x1d
KEY_RCTRL KEYSC_RCTRL 0x9d
KEY_LSHIFT KEYSC_LSHIFT 0x2a
KEY_RSHIFT KEYSC_RSHIFT 0x36
KEY_KP1 KEYSC_gEND 0x4f Exposed Alias: "KEY_gEND"
KEY_KP2 KEYSC_gDOWN 0x50 Exposed Alias: "KEY_gDOWN"
KEY_KP3 KEYSC_gPGDN 0x51 Exposed Alias: "KEY_gPGDN"
KEY_KP4 KEYSC_gLEFT 0x4b Exposed Alias: "KEY_gLEFT"
KEY_KP5 KEYSC_gKP5 0x4c Exposed Alias: "KEY_gKP5"
KEY_KP6 KEYSC_gRIGHT 0x4d Exposed Alias: "KEY_gRIGHT"
KEY_KP7 KEYSC_gHOME 0x47 Exposed Alias: "KEY_gHOME"
KEY_KP8 KEYSC_gUP 0x48 Exposed Alias: "KEY_gUP"
KEY_KP9 KEYSC_gPGUP 0x49 Exposed Alias: "KEY_gPGUP"
KEY_KP0 KEYSC_gINS 0x52 Exposed Alias: "KEY_gINS"
KEY_KPCOMMA KEYSC_gDEL 0x53 Exposed Alias: "KEY_gDEL"
KEY_gMINUS KEYSC_gMINUS 0x4a
KEY_gPLUS KEYSC_gPLUS 0x4e
KEY_gSLASH KEYSC_gSLASH 0xB5
KEY_gSTAR KEYSC_gSTAR 0x37
KEY_SCROLL KEYSC_SCROLL 0x46
KEY_HOME KEYSC_HOME 0xc7
KEY_UP KEYSC_UP 0xc8
KEY_DOWN KEYSC_DOWN 0xd0
KEY_LEFT KEYSC_LEFT 0xcb
KEY_RIGHT KEYSC_RIGHT 0xcd
KEY_PGUP KEYSC_PGUP 0xc9
KEY_PGDN KEYSC_PGDN 0xd1
KEY_END KEYSC_END 0xcf
KEY_INSERT KEYSC_INSERT 0xd2
KEY_DELETE KEYSC_DELETE 0xd3
KEY_F1 KEYSC_F1 0x3b
KEY_F2 KEYSC_F2 0x3c
KEY_F3 KEYSC_F3 0x3d
KEY_F4 KEYSC_F4 0x3e
KEY_F5 KEYSC_F5 0x3f
KEY_F6 KEYSC_F6 0x40
KEY_F7 KEYSC_F7 0x41
KEY_F8 KEYSC_F8 0x42
KEY_F9 KEYSC_F9 0x43
KEY_F10 KEYSC_F10 0x44
KEY_F11 KEYSC_F11 0x57
KEY_F12 KEYSC_F12 0x58
N/A KEYSC_ESC 0x01 Not exposed.
N/A KEYSC_CAPS 0x3a Not exposed.
N/A KEYSC_gNUM 0x45 Not exposed.
N/A KEYSC_gENTER 0x9c Not exposed.
N/A KEYSC_PRTSCN 0xb7 Not exposed. Printscreen.
N/A KEYSC_PAUSE 0xc5 Not exposed.
Keyboard Layout from mapster32.cfg
; Key Settings
;  Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!
; +---------------------------------------------------------------------------------------------+
; | 01   3B  3C  3D  3E   3F  40  41  42   43  44  57  58          46                           |
; |ESC   F1  F2  F3  F4   F5  F6  F7  F8   F9 F10 F11 F12        SCROLL                         |
; |                                                                                             |
; |29  02  03  04  05  06  07  08  09  0A  0B  0C  0D   0E     D2  C7  C9      45  B5  37  4A   |
; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0'  -   =  BACK    INS HOME PGUP  NUMLK KP/ KP* KP-  |
; |                                                                                             |
; | 0F  10  11  12  13  14  15  16  17  18  19  1A  1B  2B     D3  CF  D1      47  48  49  4E   |
; |TAB  Q   W   E   R   T   Y   U   I   O   P   [   ]    \    DEL END PGDN    KP7 KP8 KP9 KP+   |
; |                                                                                             |
; | 3A   1E  1F  20  21  22  23  24  25  26  27  28     1C                     4B  4C  4D       |
; |CAPS  A   S   D   F   G   H   J   K   L   ;   '   ENTER                    KP4 KP5 KP6    9C |
; |                                                                                      KPENTER|
; |  2A    2C  2D  2E  2F  30  31  32  33  34  35    36            C8          4F  50  51       |
; |LSHIFT  Z   X   C   V   B   N   M   ,   .   /   RSHIFT          UP         KP1 KP2 KP3       |
; |                                                                                             |
; | 1D     38              39                  B8     9D       CB  D0   CD      52    53        |
; |LCTRL  LALT           SPACE                RALT   RCTRL   LEFT DOWN RIGHT    KP0    KP.      |
; +---------------------------------------------------------------------------------------------+

The following keys cannot be updated by ifhitkey, setkey or resetkey:

{ KEYSC_ESC, KEYSC_gENTER, KEYSC_LALT, KEYSC_RALT, KEYSC_LCTRL, KEYSC_RCTRL, KEYSC_LSHIFT, KEYSC_RSHIFT, KEYSC_BQUOTE, KEYSC_TILDE }