2 # Documentation for SCA_KeyboardSensor
3 from SCA_ISensor import *
5 class SCA_KeyboardSensor(SCA_ISensor):
7 A keyboard sensor detects player key presses.
9 See module L{GameKeys} for keycode values.
11 @ivar key: The key code this sensor is looking for.
12 @type key: keycode from L{GameKeys} module
13 @ivar hold1: The key code for the first modifier this sensor is looking for.
14 @type hold1: keycode from L{GameKeys} module
15 @ivar hold2: The key code for the second modifier this sensor is looking for.
16 @type hold2: keycode from L{GameKeys} module
17 @ivar toggleProperty: The name of the property that indicates whether or not to log keystrokes as a string.
18 @type toggleProperty: string
19 @ivar targetProperty: The name of the property that receives keystrokes in case in case a string is logged.
20 @type targetProperty: string
21 @ivar useAllKeys: Flag to determine whether or not to accept all keys.
22 @type useAllKeys: boolean
23 @ivar events: a list of pressed keys that have either been pressed, or just released, or are active this frame. (read only).
25 - 'keycode' matches the values in L{GameKeys}.
27 - L{GameLogic.KX_INPUT_NONE}
28 - L{GameLogic.KX_INPUT_JUST_ACTIVATED}
29 - L{GameLogic.KX_INPUT_ACTIVE}
30 - L{GameLogic.KX_INPUT_JUST_RELEASED}
32 @type events: list [[keycode, status], ...]
36 Get a list of pressed keys that have either been pressed, or just released, or are active this frame.
38 B{DEPRECATED: Use the "events" property instead}.
40 @rtype: list of key status. [[keycode, status]]
41 @return: A list of keyboard events
44 def getKeyStatus(keycode):
46 Get the status of a key.
48 @rtype: key state L{GameLogic} members (KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED)
49 @return: The state of the given key
50 @type keycode: integer
51 @param keycode: The code that represents the key you want to get the state of
54 #--The following methods are DEPRECATED--
57 Returns the key code this sensor is looking for.
59 B{DEPRECATED: Use the "key" property instead}.
61 @rtype: keycode from L{GameKeys} module
66 Set the key this sensor should listen for.
68 B{DEPRECATED: Use the "key" property instead}.
70 @type keycode: keycode from L{GameKeys} module
75 Returns the key code for the first modifier this sensor is looking for.
77 B{DEPRECATED: Use the "hold1" property instead}.
79 @rtype: keycode from L{GameKeys} module
82 def setHold1(keycode):
84 Sets the key code for the first modifier this sensor should look for.
86 B{DEPRECATED: Use the "hold1" property instead}.
88 @type keycode: keycode from L{GameKeys} module
93 Returns the key code for the second modifier this sensor is looking for.
95 B{DEPRECATED: Use the "hold2" property instead}.
97 @rtype: keycode from L{GameKeys} module
100 def setHold2(keycode):
102 Sets the key code for the second modifier this sensor should look for.
104 B{DEPRECATED: Use the "hold2" property instead.}
106 @type keycode: keycode from L{GameKeys} module
109 def getPressedKeys():
111 Get a list of keys that have either been pressed, or just released this frame.
113 B{DEPRECATED: Use "events" instead.}
115 @rtype: list of key status. [[keycode, status]]
118 def getCurrentlyPressedKeys():
120 Get a list of currently pressed keys that have either been pressed, or just released
122 B{DEPRECATED: Use "events" instead.}
124 @rtype: list of key status. [[keycode, status]]