Difference between revisions of "Key.keyNames"

From MiniScript Wiki
Jump to navigation Jump to search
(Added some sample output and explanation about key.keyNames values vs key.get values.)
Line 9: Line 9:
  
 
<ms>while true
 
<ms>while true
     for n in key.keyNames
+
     while true
        if key.pressed(n) then print n
+
for n in key.keyNames
    end for
+
if key.pressed(n) then
 +
while key.pressed(n)
 +
end while
 +
print n
 +
end if
 +
end for
 
end while</ms>
 
end while</ms>
  

Revision as of 03:01, 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 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.

Though some values may overlap, the values from key.keyNames are not always the same that are received from key.get. Characters such as upper case letters, arrow keys, etc., as returned from key.get cannot be used in key.pressed.

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