Difference between revisions of "Key.keyNames"

From MiniScript Wiki
Jump to navigation Jump to search
m (Fixed broken link and moved "See also" to bottom of page above category)
m (Deleted redundant `while true`)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<c>[[key]].keyNames</c> returns a list of all the key names available for use with [[key.pressed]].
+
<c>[[key]].keyNames</c> returns a list of all the key names available for use with <c>[[key.pressed]]</c>.  
  
 
=== Usage Notes ===
 
=== Usage Notes ===
This can be used, for example, to check all possible inputs, if waiting for the user to press anything to continue, or while configuring their
+
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.
input preferences.
 
  
== Example ==
+
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 ==
  
 
<ms>while true
 
<ms>while true
    for n in key.keyNames
+
for n in key.keyNames
        if key.pressed(n) then print n
+
if key.pressed(n) then
    end for
+
while key.pressed(n)
 +
end while
 +
print n
 +
end if
 +
end for
 
end while</ms>
 
end while</ms>
  
See also: <c>[[key.pressed]]</c>
+
See also: <c>[[key.pressed]]</c>, <c>[[key]]</c>
 +
 
 +
== Sample Output ==
 +
<div class="toccolours mw-collapsible mw-collapsed">
 +
Windows 10 sample output:
 +
<div class="mw-collapsible-content">
 +
a</br>
 +
b</br>
 +
c</br>
 +
d</br>
 +
e</br>
 +
f</br>
 +
g</br>
 +
h</br>
 +
i</br>
 +
j</br>
 +
k</br>
 +
l</br>
 +
m</br>
 +
n</br>
 +
o</br>
 +
p</br>
 +
q</br>
 +
r</br>
 +
s</br>
 +
t</br>
 +
u</br>
 +
v</br>
 +
w</br>
 +
x</br>
 +
y</br>
 +
z</br>
 +
1</br>
 +
2</br>
 +
3</br>
 +
4</br>
 +
5</br>
 +
6</br>
 +
7</br>
 +
8</br>
 +
9</br>
 +
0</br>
 +
-</br>
 +
=</br>
 +
[</br>
 +
]</br>
 +
\</br>
 +
,</br>
 +
.</br>
 +
/</br>
 +
&#59;</br>
 +
'</br>
 +
`</br>
 +
f1</br>
 +
f2</br>
 +
f3</br>
 +
f4</br>
 +
f5</br>
 +
f6</br>
 +
f7</br>
 +
f8</br>
 +
f9</br>
 +
f10</br>
 +
f11</br>
 +
f12</br>
 +
f13</br>
 +
f14</br>
 +
f15</br>
 +
up</br>
 +
down</br>
 +
left</br>
 +
right</br>
 +
[1]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[2]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[3]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[4]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[5]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[6]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[7]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[8]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[9]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[0]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[+]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[-]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[*]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
[/]&nbsp;&nbsp;&nbsp; // keypad input</br>
 +
enter</br>
 +
equals</br>
 +
clear</br>
 +
left shift</br>
 +
right shift</br>
 +
left ctrl</br>
 +
right ctrl</br>
 +
left alt</br>
 +
right alt</br>
 +
left cmd</br>
 +
right cmd</br>
 +
backspace</br>
 +
tab</br>
 +
return</br>
 +
escape</br>
 +
space</br>
 +
delete</br>
 +
insert</br>
 +
home</br>
 +
end</br>
 +
page up</br>
 +
page down</br>
 +
mouse 0</br>
 +
mouse 1</br>
 +
mouse 2</br>
 +
mouse 3</br>
 +
mouse 4</br>
 +
mouse 5</br>
 +
mouse 6</br>
 +
joystick button 0</br>
 +
joystick button 1</br>
 +
joystick button 2</br>
 +
joystick button 3</br>
 +
joystick button 4</br>
 +
joystick button 5</br>
 +
joystick button 6</br>
 +
joystick button 7</br>
 +
joystick button 8</br>
 +
joystick button 9</br>
 +
joystick button 10</br>
 +
joystick button 11</br>
 +
joystick button 12</br>
 +
joystick button 13</br>
 +
joystick button 14</br>
 +
joystick button 15</br>
 +
joystick 1 button 0</br>
 +
joystick 1 button 1</br>
 +
joystick 1 button 2</br>
 +
joystick 1 button 3</br>
 +
joystick 1 button 4</br>
 +
joystick 1 button 5</br>
 +
joystick 1 button 6</br>
 +
joystick 1 button 7</br>
 +
joystick 1 button 8</br>
 +
joystick 1 button 9</br>
 +
joystick 1 button 10</br>
 +
joystick 1 button 11</br>
 +
joystick 1 button 12</br>
 +
joystick 1 button 13</br>
 +
joystick 1 button 14</br>
 +
joystick 1 button 15</br>
 +
joystick 2 button 0</br>
 +
joystick 2 button 1</br>
 +
joystick 2 button 2</br>
 +
joystick 2 button 3</br>
 +
joystick 2 button 4</br>
 +
joystick 2 button 5</br>
 +
joystick 2 button 6</br>
 +
joystick 2 button 7</br>
 +
joystick 2 button 8</br>
 +
joystick 2 button 9</br>
 +
joystick 2 button 10</br>
 +
joystick 2 button 11</br>
 +
joystick 2 button 12</br>
 +
joystick 2 button 13</br>
 +
joystick 2 button 14</br>
 +
joystick 2 button 15</br>
 +
joystick 3 button 0</br>
 +
joystick 3 button 1</br>
 +
joystick 3 button 2</br>
 +
joystick 3 button 3</br>
 +
joystick 3 button 4</br>
 +
joystick 3 button 5</br>
 +
joystick 3 button 6</br>
 +
joystick 3 button 7</br>
 +
joystick 3 button 8</br>
 +
joystick 3 button 9</br>
 +
joystick 3 button 10</br>
 +
joystick 3 button 11</br>
 +
joystick 3 button 12</br>
 +
joystick 3 button 13</br>
 +
joystick 3 button 14</br>
 +
joystick 3 button 15</br>
 +
joystick 4 button 0</br>
 +
joystick 4 button 1</br>
 +
joystick 4 button 2</br>
 +
joystick 4 button 3</br>
 +
joystick 4 button 4</br>
 +
joystick 4 button 5</br>
 +
joystick 4 button 6</br>
 +
joystick 4 button 7</br>
 +
joystick 4 button 8</br>
 +
joystick 4 button 9</br>
 +
joystick 4 button 10</br>
 +
joystick 4 button 11</br>
 +
joystick 4 button 12</br>
 +
joystick 4 button 13</br>
 +
joystick 4 button 14</br>
 +
joystick 4 button 15</br>
 +
</div>
 +
</div>
 +
 
  
 
[[Category:Mini Micro]]
 
[[Category:Mini Micro]]

Latest revision as of 19:01, 13 December 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
	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