input¶
Overview¶
Inputs from keyboards and mouses.
Name | Description | Returns | Parameters |
---|---|---|---|
getKey | Get statue of holding down appointed ke | boolen | getKey(keyCode) |
getKeyDown | Get statue of pressing appointed key | boolen | getKeyDown(keyCode) |
getKeyUp | Get statue of releasing appointed key | boolen | getKeyUp(keyCode) |
getMouseButton | Get statue of pressing a mouse button | boolen | getMouseButton(MouseCode) |
getMouseButtonDown | Get statue of pressing a mouse button | boolen | getMouseButtonDown(MouseCode) |
getMouseButtonUp | Get statue of releasing the mouse button | boolen | getMouseButtonUp(MouseCode) |
input.getKey¶
Check if user press and holds specific key.
Parameters¶
Name | Description |
---|---|
keyCode | KeyCode raw key code for keyboard events. |
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | Player = {
obj : null,
function Update() {
//if user holds down key A, rotate obj -5 degree around its Y axis
if (input.getKey(KeyCode.A)) this.obj.yaw(-5);
//if user holds down key D, rotate obj 5 degree around its Y axis
if (input.getKey(KeyCode.D)) this.obj.yaw(5);
//if user holds down key R, move obj to Vector3(3,0,3) in 2 seconds
if (input.getKeyDown(KeyCode.R)) this.obj.moveTo(Vector3(3,0,3),2);
//if user holds down key R, move obj to Vector3(-3,0,-3) in 2 second
if (input.getKeyUp(KeyCode.R)) this.obj.moveTo(Vector3(-3,0,-3),2);
//if user clicks the left mouse button, print ' Pressed left click'
if (input.getMouseButtonDown(0)) print("Pressed left click ");
//if user clicks the right mouse button,print'Pressed right click'
if (input.getMouseButtonDown(1)) print("Pressed right click ");
}
}
var obj = object.create("0bcba8ca78734b64a3dae3eb699a913c");
var script = obj.addScript(Player);
script.obj = obj;
camera.enableMove = false;input.getKeyDown(keyCode);
|
input.getKeyDown¶
Check if user press specific key.
Parameters¶
Name | Description |
---|---|
keyCode | KeyCode raw key code for keyboard events. |
input.getKeyUp¶
Check if user release specific key.
Parameters¶
Name | Description |
---|---|
keyCode | KeyCode raw key code for keyboard events. |
input.getMouseButton¶
Check if user click and hold mouse button.
Parameters¶
Name | Description |
---|---|
MouseCode | int raw key code for mouse events. |