Update Home
parent
214d5e741d
commit
b1724e921c
116
Home.md
116
Home.md
@ -80,6 +80,122 @@ First, you must import it to allocate memory in the engine for your Lua script.
|
||||
|
||||
|
||||
|
||||
|
||||
## KeyCode
|
||||
|
||||
The `KeyCode` defines constants for all the keys available in the system. These constants are mapped to their respective key codes, allowing a standardized way to handle keyboard input.
|
||||
|
||||
### KeyCode Values
|
||||
Here is a list of all the available key codes:
|
||||
|
||||
#### Alphanumeric Keys
|
||||
- `KeyCode.A` to `KeyCode.Z`: Letters A to Z
|
||||
- `KeyCode.D0` to `KeyCode.D9`: Digits 0 to 9
|
||||
|
||||
#### Punctuation and Special Characters
|
||||
- `KeyCode.Space`: Spacebar
|
||||
- `KeyCode.Apostrophe`: '
|
||||
- `KeyCode.Comma`: ,
|
||||
- `KeyCode.Minus`: -
|
||||
- `KeyCode.Period`: .
|
||||
- `KeyCode.Slash`: /
|
||||
- `KeyCode.Semicolon`: ;
|
||||
- `KeyCode.Equal`: =
|
||||
- `KeyCode.LeftBracket`: [
|
||||
- `KeyCode.Backslash`: \
|
||||
- `KeyCode.RightBracket`: ]
|
||||
- `KeyCode.GraveAccent`: `
|
||||
|
||||
#### Function Keys
|
||||
- `KeyCode.F1` to `KeyCode.F25`: Function keys F1 through F25
|
||||
|
||||
#### Arrow Keys
|
||||
- `KeyCode.Up`: Up Arrow
|
||||
- `KeyCode.Down`: Down Arrow
|
||||
- `KeyCode.Left`: Left Arrow
|
||||
- `KeyCode.Right`: Right Arrow
|
||||
|
||||
#### Navigation Keys
|
||||
- `KeyCode.Home`: Home
|
||||
- `KeyCode.End`: End
|
||||
- `KeyCode.PageUp`: Page Up
|
||||
- `KeyCode.PageDown`: Page Down
|
||||
|
||||
#### System Keys
|
||||
- `KeyCode.Escape`: Escape
|
||||
- `KeyCode.Enter`: Enter
|
||||
- `KeyCode.Tab`: Tab
|
||||
- `KeyCode.Backspace`: Backspace
|
||||
- `KeyCode.Insert`: Insert
|
||||
- `KeyCode.Delete`: Delete
|
||||
|
||||
#### Modifier Keys
|
||||
- `KeyCode.LeftShift`, `KeyCode.RightShift`: Left and Right Shift
|
||||
- `KeyCode.LeftControl`, `KeyCode.RightControl`: Left and Right Control
|
||||
- `KeyCode.LeftAlt`, `KeyCode.RightAlt`: Left and Right Alt
|
||||
- `KeyCode.LeftSuper`, `KeyCode.RightSuper`: Left and Right Super (e.g., Windows key)
|
||||
- `KeyCode.Menu`: Menu Key
|
||||
|
||||
#### Keypad Keys
|
||||
- `KeyCode.KP0` to `KeyCode.KP9`: Keypad numbers 0 to 9
|
||||
- `KeyCode.KPDecimal`: Decimal point on the keypad
|
||||
- `KeyCode.KPDivide`: Divide on the keypad
|
||||
- `KeyCode.KPMultiply`: Multiply on the keypad
|
||||
- `KeyCode.KPSubtract`: Subtract on the keypad
|
||||
- `KeyCode.KPAdd`: Add on the keypad
|
||||
- `KeyCode.KPEnter`: Enter on the keypad
|
||||
- `KeyCode.KPEqual`: Equal on the keypad
|
||||
|
||||
#### Lock Keys
|
||||
- `KeyCode.CapsLock`: Caps Lock
|
||||
- `KeyCode.NumLock`: Num Lock
|
||||
- `KeyCode.ScrollLock`: Scroll Lock
|
||||
|
||||
#### Miscellaneous Keys
|
||||
- `KeyCode.PrintScreen`: Print Screen
|
||||
- `KeyCode.Pause`: Pause
|
||||
- `KeyCode.World1`, `KeyCode.World2`: Additional international keys
|
||||
|
||||
---
|
||||
|
||||
## `Engine.KeyDown` Function
|
||||
|
||||
### Description
|
||||
The `Engine.KeyDown` function checks if a specific key is currently pressed.
|
||||
|
||||
### Syntax
|
||||
```lua
|
||||
Engine.KeyDown(keyCode)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
- `keyCode`: A value from the `KeyCode` enumeration representing the key to check.
|
||||
|
||||
### Returns
|
||||
- `true` if the specified key is pressed.
|
||||
- `false` if the specified key is not pressed.
|
||||
|
||||
### Example Usage
|
||||
```lua
|
||||
local KeyCode = require("./assets/scripts/keycode")
|
||||
|
||||
-- Check if the "W" key is pressed
|
||||
if Engine.KeyDown(KeyCode.W) then
|
||||
print("W key is pressed")
|
||||
end
|
||||
|
||||
-- Check if the Space key is pressed
|
||||
if Engine.KeyDown(KeyCode.Space) then
|
||||
print("Space key is pressed")
|
||||
end
|
||||
```
|
||||
|
||||
This function is ideal for handling real-time input, such as moving a character in a game or interacting with UI elements.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Math Library Wiki
|
||||
|
||||
## Overview
|
||||
|
Loading…
Reference in New Issue
Block a user