Input
Input
这个静态类型用来提供输入功能。基本的输入系统并不是基于事件绑定的,而是采用轮询的方式。这部分内容比较直观,一般来说看函数名就知道用法,但也会有几个坑。
Key Reading
There's a number of useful methods that detect keys being pressed down in different ways, all seeming to return a 'bool'. Most common are IsKeyDown
, IsKeyPressed
and IsKeyReleased
You can call them like so: Input.IsKeyDown(InputKey.TheKeyCode)
. See here for a list of all keycodes: link
You can also use the extension methods IsDown
/IsPressed
/IsReleased
as such KeyCode.A.IsPressed()
Below, you may find an in-depth documentation of each.
Namespace
This page assumes an import like so: using TaleWorlds.InputSystem;
public static bool Input.IsKeyDown(InputKey key)
This checks to see if the specified [key] is currently being pressed, it returns true as long as the [key] is held down.
Example:
public static bool Input.IsKeyDownImmediate(InputKey key)
This acts as an intermediary check between IsKeyDown
and IsKeyPressed
Example:
public static bool Input.IsKeyPressed(InputKey key)
This checks to see if the specified [key] has been pressed, it returns a bool once.
Example:
public static bool Input.IsKeyReleased(InputKey key)
This checks to see if the specified [key] is not currently being pressed, it returns a bool once.
Example:
To see how one could document the stages of a key using the above 3 methods: example
public static bool Input.IsControlOrShiftNotDown()
I do not believe there is any other method more self-explanatory than this. Returns true while neither Control or Shift are down.
public static bool Input.IsPressed(InputKey key)
Checks to see if a they specified [key] is currently pressed. Unlike IsDown, it can be used as Input.IsPressed() but not as an extension.
public static Vector2 Input.GetKeyState(InputKey key)
Checks and returns the current state of the specified [key] as a Vector2. I am not aware how this can be used.
Example:
public static string Input.GetKeyboardText()
Returns the text currently existing in the user's clipboard as a string.
public static bool Input.IsMouseActive
Checks to see if the mouse is currently active, if so returns true
.
public static bool Input.IsMouseScrollChanged
Checks to see if the mouse scroll wheel is currently rotating, if so returns true
.
public static float Input.MouseMoveX
Returns the horizontal position of the mouse as a float.
public static float Input.MouseMoveY
Returns the vertical position of the mouse as a float.
Examples
Monitoring a key's state
Key Codes
As of Bannerlord 1.2.1 the following key codes are available:
Last updated