Simple javascript input manager. Listen to keyboard+mouse combinations easily. Now with experimental gamepad support
Simple javascript input manager. Listen to key+mouse combinations easily. Now with experimental gamepad support.
GAMEPUT.bind(combinations, callback, prevent_repeat)
: binds the given combinations to the callback. This function does not support gamepads yetGAMEPUT.isPressed(combinations)
: Returns true if any of the combinations is being pressed at the moment the function is called.GAMEPUT.getGamepads()
: Returns the connected gamepads as an array.GAMEPUT.getAxis(name)
: Returns the state of the named axis, a number between -1.0 and 1.0.shift + J
or control + 9
combination:GAMEPUT.bind("shift+j control+9", function(e) { /* Do stuff */ });
G + Left mouse button
:GAMEPUT.bind("g+mouseleft", function(e) { /* Do other stuff */ });
GAMEPUT.isPressed("p+e+altgr+mousecenter");
GAMEPUT.isPressed("gamepad3/R2")
GAMEPUT.getAxis("gamepad1/rightanaloguevert")
GAMEPUT.isPressed("gamepad1/button/836")
backspace
tab
enter
shift
control
alt
capslock
altgr
del
pagedown
pageup
end
home
left
up
right
down
boardplus
: The plus sign in the main keyboard (not the numeric pad)numpadplus
: The plus sign in the numeric padplus
: Triggers by pressing boardplus
or numpadplus
.boardhyphen
: Hyphen in the main keyboardnumpadhyphen
: Hyphen in the numeric padhyphen
: boardhyphen
or numpadhyphen
minus
: Same as hyphen
space
leftwindows
: Left Windows keyrightwindows
: Right Windows keywindows
: leftwindows
or rightwindows
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
numpad0
numpad1
numpad2
numpad3
numpad4
numpad5
numpad6
numpad7
numpad8
numpad9
: Numbers in the numeric padboard0
board1
board2
board3
board4
board5
board6
board7
board8
board9
: Numbers in the main keyboard0
1
2
3
4
5
6
7
8
9
: Numbers in the numeric pad or the main keyboardmouseleft
mouseright
mousecenter
mousecentre
: Same as mousecenter
click
: Any mouse buttonThe gamepads have an special notation, as there can be more than one gamepad connected. The format is gamepad_name/button_or_axis_name
gamepad1
gamepad2
gamepad3
gamepad4
… : The gamepad names are just the word gamepad followed by its number1
2
3
4
L1
L2
R1
R2
start
select
leftanalogue
rightanalogue
padup
paddown
padleft
padright
: The buttons of the gamepad. A gamepad might not have some of these buttons, but this list responds to a standard in gamepads. The analogue buttons are analogue sticks pressed.leftanaloguehor
leftanaloguevert
rightanaloguehor
rightanaloguevert
: The standard axes. When asking about an axis with the GAMEPUT.isPressed
function, if will only return true if the axis is pressed beyond the 0.1 or the -0.1 threshold.There’s another way to ask about the buttons and axes, in case you don’t like these names, or if you need more buttons and axes.
button/1
button/2
button/3
button/4
… : A button identified by its number.axis/1
axis/2
axis/3
axis/4
… : An axis identified by its number.