Key.keyNames

From MiniScript Wiki
Revision as of 19:01, 13 December 2023 by Marc Gurevitx (talk | contribs) (Deleted redundant `while true`)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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
	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