Difference between revisions of "Key.keyNames"
m (→Example 1) |
|||
Line 2: | Line 2: | ||
=== Usage Notes === | === Usage Notes === | ||
− | This can be used to check all possible button-like inputs (keypresses, joystick buttons, etc). For example: if waiting for the user to press anything to continue or while configuring their input preferences. | + | This can be used to check (via <c>[[key.pressed]]</c>) all possible button-like inputs (keypresses, joystick buttons, etc). For example: if waiting for the user to press anything to continue or while configuring their input preferences. |
− | + | Note the values from <c>[[key]].keyNames</c> are not the same that are received from <c>[[key.get]]</c>. <c>[[key.get]]</c> returns characters including upper- and lower-case letters, etc., which may be generated by a single key or some key combination (such as shift-4 for $ on a U.S. keyboard), whereas <c>[[key]].keyNames</c> and <c>[[key.pressed]]</c> refer to physical hardware keys, regardless of what character (if any) they generate. | |
== Example 1 == | == Example 1 == |
Revision as of 15:09, 26 October 2023
key.keyNames
returns a list of all the key names available for use with key.pressed
.
Usage Notes
This can be used to check (via key.pressed
) all possible button-like inputs (keypresses, joystick buttons, etc). For example: if waiting for the user to press anything to continue or while configuring their input preferences.
Note the values from key.keyNames
are not the same that are received from key.get
. key.get
returns characters including upper- and lower-case letters, etc., which may be generated by a single key or some key combination (such as shift-4 for $ on a U.S. keyboard), whereas key.keyNames
and key.pressed
refer to physical hardware keys, regardless of what character (if any) they generate.
Example 1
while true
while true
for n in key.keyNames
if key.pressed(n) then
while key.pressed(n)
end while
print n
end if
end for
end while
See also: key.pressed
, key
Sample Output
Windows 10 sample output:
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
1
2
3
4
5
6
7
8
9
0
-
=
[
]
\
,
.
/
;
'
`
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
f13
f14
f15
up
down
left
right
[1] // keypad input
[2] // keypad input
[3] // keypad input
[4] // keypad input
[5] // keypad input
[6] // keypad input
[7] // keypad input
[8] // keypad input
[9] // keypad input
[0] // keypad input
[+] // keypad input
[-] // keypad input
[*] // keypad input
[/] // keypad input
enter
equals
clear
left shift
right shift
left ctrl
right ctrl
left alt
right alt
left cmd
right cmd
backspace
tab
return
escape
space
delete
insert
home
end
page up
page down
mouse 0
mouse 1
mouse 2
mouse 3
mouse 4
mouse 5
mouse 6
joystick button 0
joystick button 1
joystick button 2
joystick button 3
joystick button 4
joystick button 5
joystick button 6
joystick button 7
joystick button 8
joystick button 9
joystick button 10
joystick button 11
joystick button 12
joystick button 13
joystick button 14
joystick button 15
joystick 1 button 0
joystick 1 button 1
joystick 1 button 2
joystick 1 button 3
joystick 1 button 4
joystick 1 button 5
joystick 1 button 6
joystick 1 button 7
joystick 1 button 8
joystick 1 button 9
joystick 1 button 10
joystick 1 button 11
joystick 1 button 12
joystick 1 button 13
joystick 1 button 14
joystick 1 button 15
joystick 2 button 0
joystick 2 button 1
joystick 2 button 2
joystick 2 button 3
joystick 2 button 4
joystick 2 button 5
joystick 2 button 6
joystick 2 button 7
joystick 2 button 8
joystick 2 button 9
joystick 2 button 10
joystick 2 button 11
joystick 2 button 12
joystick 2 button 13
joystick 2 button 14
joystick 2 button 15
joystick 3 button 0
joystick 3 button 1
joystick 3 button 2
joystick 3 button 3
joystick 3 button 4
joystick 3 button 5
joystick 3 button 6
joystick 3 button 7
joystick 3 button 8
joystick 3 button 9
joystick 3 button 10
joystick 3 button 11
joystick 3 button 12
joystick 3 button 13
joystick 3 button 14
joystick 3 button 15
joystick 4 button 0
joystick 4 button 1
joystick 4 button 2
joystick 4 button 3
joystick 4 button 4
joystick 4 button 5
joystick 4 button 6
joystick 4 button 7
joystick 4 button 8
joystick 4 button 9
joystick 4 button 10
joystick 4 button 11
joystick 4 button 12
joystick 4 button 13
joystick 4 button 14
joystick 4 button 15