add doc/en/scripting/user-input.md
This commit is contained in:
parent
fc64d04333
commit
1081c74afb
61
doc/en/scripting/user-input.md
Normal file
61
doc/en/scripting/user-input.md
Normal file
@ -0,0 +1,61 @@
|
||||
# User input
|
||||
|
||||
User input is performed with *bindings* defined with `config/bindings.toml`.
|
||||
|
||||
Example:
|
||||
|
||||
```toml
|
||||
packid.binding.name="inputtype:codename"
|
||||
```
|
||||
|
||||
- packid - optional (recommended)
|
||||
- inputtype - key or mouse
|
||||
- codename - key or mouse button code (left/right/middle)
|
||||
|
||||
## Key names
|
||||
|
||||
- space, backspace, tab, enter, caps-lock, escape
|
||||
- left-ctrl, left-shift, left-alt, left-super
|
||||
- right-ctrl, right-shift, right-alt, right-super
|
||||
- delete, home, end, insert, page-up, page-down
|
||||
- left, right, down, up
|
||||
- a..z
|
||||
- 0..9
|
||||
- f1..f25
|
||||
|
||||
## *input* library
|
||||
|
||||
```python
|
||||
input.keycode(keyname: str) -> int
|
||||
```
|
||||
|
||||
Returns key code or -1 if unknown
|
||||
|
||||
```python
|
||||
input.mousecode(mousename: str) -> int
|
||||
```
|
||||
|
||||
Returns mouse button code or -1 if unknown
|
||||
|
||||
```python
|
||||
input.add_callback(bindname: str, callback: function)
|
||||
```
|
||||
|
||||
Add binding activation callback. Example:
|
||||
```lua
|
||||
input.add_callback("hud.inventory", function ()
|
||||
print("Inventory open key pressed")
|
||||
end)
|
||||
```
|
||||
|
||||
```python
|
||||
input.get_mouse_pos() -> {int, int}
|
||||
```
|
||||
|
||||
Returns cursor screen position.
|
||||
|
||||
```python
|
||||
input.get_bindings() -> strings array
|
||||
```
|
||||
|
||||
Returns all binding names.
|
||||
Loading…
x
Reference in New Issue
Block a user