.. _is_features: Features ======== Okay, so why do you need an input system? If you ever wanted your player to move right with multiple inputs you did something like this: .. raw:: html
var right = keyboard_check(vk_right) or keyboard_check(ord("D"))
or gamepad_button_check(0, gp_padr) or gamepad_axis_value(0, gp_axislh) > 0;
Thats pretty long isn’t it! Well with this input system you could do this:
.. raw:: html
var right = inputCheck([vk_right, "d", gp_padr, gp_axislr]);
Read more about the :code:`inputCheck()` function :ref:`here
// Create event
in_sys = new InputSystem({
right: [vk_right, "d", gp_padr, gp_axislr],
left: [vk_left, "a", gp_padl, gp_axisll],
jump: [vk_up, "w", gp_a],
shoot: [vk_space, gp_shoulderrb, gp_x]
});
// Step event
var input = in_sys.check();
if (input.right.down) x += 4;
if (input.left.down) x -= 4;
if (input.jump.pressed) y -= 10;
if (input.shoot.down) shoot();
As you can see first you create a new InputSystem with the categories and inputs.
Then you can call the InputSystem's check method which will check if any of the inputs are pressed.
After that you can get the inputs in three ways:
* .down - Returns :code:`true` continuously if any of the inputs are currently held down
* .pressed - Returns :code:`true` only at the moment when any of the inputs are pressed
* .released - Return :code:`true` only at the moment when the input is released
Read more about the :code:`InputSystem()` :ref:`here