Difference between revisions of "IsKeyPressed2"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>DragoonWraith
(messed up Note)
imported>DragoonWraith
(DX scancode list)
Line 8: Line 8:
DirectX scancodes are typically in hexadecimal, but this function takes decimal values.
DirectX scancodes are typically in hexadecimal, but this function takes decimal values.


<!--==Sample Key IDs==
==Sample Key DX Scancodes==
<pre>
<pre>
Left Mouse Button
Hex  Dec  Button
2   Right Mouse Button
0x01    1  Escape
4   Middle Mouse Button
0x02    2  1
0x03    3  2
0x04    4  3
...
0x09    9  8
0x0A   10  9
0x0B  11  0
---
0x10  16  Q
0x11  17  W
0x12  18  E
...
0x17  23  I
0x18   24  O
0x19   25  P
---
---
13 Enter
0x1C  28 Enter
0x1D  29  Left Control
---
---
20 Caps Lock
0x1E  30 A
0x1F  31  S
0x20  32  D
...
0x24  36  J
0x25  37  K
0x26  38  L
---
---
32 spacebar
0x2A  42 Left Shift
---
---
48 0
0x2C  44 Z
49 1
0x2D  45 X
50 2
0x2E  46 C
...
...
55 7
0x30  47 B
56 8
0x31  48 N
57 9
0x32  49 M
---
---
65 A
0x36  54 Right Shift
66 B
0x37  55 NUM*
67 C
0x38  56 Left Alt
0x39  57  Spacebar
0x3A  58  Caps Lock
---
0x3B  59  F1
0x3C  60  F2
0x3D  61  F3
...
...
88 X
0x43  66 F8
89 Y
0x44  67 F9
90 Z
0x45  68 F10
---
0x47  70  NUM7
0x48  71  NUM8
0x49  72  NUM9
0x4A  73  NUM-
0x4B  74  NUM4
0x4C  75  NUM5
0x4D  76  NUM6
0x4E  77  NUM+
0x4F  78  NUM1
0x50  79  NUM2
0x51  80  NUM3
0x52  81  NUM0
0x53  82  NUM.
---
0x54  83  F11
0x55  84  F12
---
0x9C  156  NUM Enter
---
0x9D  157  Right Control
---
---
96 NUM0
0xB5 181 NUM/
97 NUM1
98  NUM2
...
103 NUM7
104 NUM8
105 NUM9
106 NUM*
107 NUM+
109 NUM-
111 NUM/
---
---
112 F1
0xB8  184  Right Alt
113 F2
114 F3
...
123 F12
...
127 F16
---
---
160 left shift
0xC8  200  Up Arrow
161 right shift
0xCB  203  Left Arrow
162 left control
0xCD  205  Right Arrow
163 right control
0xD0  208  Down Arrow
</pre>
</pre>
A longer list can be found [http://www.tronan.com/macromachine/scripthelp/VK.htm here]-->
A longer list can be found [http://www.gamespp.com/directx/directInputKeyboardScanCodes.html here].


==Notes==
==Notes==

Revision as of 22:16, 9 August 2006

A command for Oblivion Script Extender

Syntax:

IsKeyPressed2 key

Returns true if key is currently pressed down. Key values are DirectX scancodes, as opposed to IsKeyPressed's Windows header codes.

DirectX scancodes are typically in hexadecimal, but this function takes decimal values.

Sample Key DX Scancodes

 Hex  Dec  Button
0x01    1  Escape
0x02    2  1
0x03    3  2
0x04    4  3
...
0x09    9  8
0x0A   10  9
0x0B   11  0
---
0x10   16  Q
0x11   17  W
0x12   18  E
...
0x17   23  I
0x18   24  O
0x19   25  P
---
0x1C   28  Enter
0x1D   29  Left Control
---
0x1E   30  A
0x1F   31  S
0x20   32  D
...
0x24   36  J
0x25   37  K
0x26   38  L
---
0x2A   42  Left Shift
---
0x2C   44  Z
0x2D   45  X
0x2E   46  C
...
0x30   47  B
0x31   48  N
0x32   49  M
---
0x36   54  Right Shift
0x37   55  NUM*
0x38   56  Left Alt
0x39   57  Spacebar
0x3A   58  Caps Lock
---
0x3B   59  F1
0x3C   60  F2
0x3D   61  F3
...
0x43   66  F8
0x44   67  F9
0x45   68  F10
---
0x47   70  NUM7
0x48   71  NUM8
0x49   72  NUM9
0x4A   73  NUM-
0x4B   74  NUM4
0x4C   75  NUM5
0x4D   76  NUM6
0x4E   77  NUM+
0x4F   78  NUM1
0x50   79  NUM2
0x51   80  NUM3
0x52   81  NUM0
0x53   82  NUM.
---
0x54   83  F11
0x55   84  F12
---
0x9C  156  NUM Enter
---
0x9D  157  Right Control
---
0xB5  181  NUM/
---
0xB8  184  Right Alt
---
0xC8  200  Up Arrow
0xCB  203  Left Arrow
0xCD  205  Right Arrow
0xD0  208  Down Arrow

A longer list can be found here.

Notes

  • Bear in mind that this function returns 1 for as long as the key is held down, so it's generally a good idea to trap the key and then wait until it is released, i.e.:
if ( curKey && isKeyPressed2 curkey ) ; key still being held down
  return ; wait until it's released
else
  set curkey to 0
endif

if ( isKeyPressed2 <keyCode> )
  ; do stuff
  set curKey to <keyCode>
endif

See Also