Difference between revisions of "KeyConstant"

(But wait, there's more!)
m (This is self explanatory but I don't know the exact wording for that)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
All the keys you can press. Note that some keys may not be available on your keyboard or system.
 
All the keys you can press. Note that some keys may not be available on your keyboard or system.
 +
 
== Constants ==
 
== Constants ==
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Key string
 
! Key string
Line 153: Line 153:
 
|
 
|
 
|-
 
|-
|(space)
+
|space  
 
|Space key
 
|Space key
|Replace (space) with the actual space character
+
|In version [[0.9.2]] and earlier this is represented by the actual space character ' '.
 
|-
 
|-
 
|!
 
|!
Line 342: Line 342:
 
|-
 
|-
 
|up
 
|up
|Up cursor key  
+
|Up arrow key  
 
|
 
|
 
|-
 
|-
 
|down
 
|down
|Down cursor key  
+
|Down arrow key  
 
|
 
|
 
|-
 
|-
 
|right
 
|right
|Right cursor key  
+
|Right arrow key  
 
|
 
|
 
|-
 
|-
 
|left
 
|left
|Left cursor key  
+
|Left arrow key  
 
|
 
|
 
|-
 
|-
Line 481: Line 481:
 
|capslock
 
|capslock
 
|Caps-lock key
 
|Caps-lock key
|Caps-on is a key press. Caps-off is a key release.
+
|
 
|-
 
|-
 
|scrolllock
 
|scrolllock
Line 521: Line 521:
 
|mode
 
|mode
 
|Mode key
 
|Mode key
 +
|
 +
|-
 +
!style="text-align: center;" colspan=3|Application keys
 +
|-
 +
|www
 +
|WWW key
 +
|
 +
|-
 +
|mail
 +
|Mail key
 +
|
 +
|-
 +
|calculator
 +
|Calculator key
 +
|
 +
|-
 +
|computer
 +
|Computer key
 +
|
 +
|-
 +
|appsearch
 +
|Application search key
 +
|
 +
|-
 +
|apphome
 +
|Application home key
 +
|
 +
|-
 +
|appback
 +
|Application back key
 +
|
 +
|-
 +
|appforward
 +
|Application forward key
 +
|
 +
|-
 +
|apprefresh
 +
|Application refresh key
 +
|
 +
|-
 +
|appbookmarks
 +
|Application bookmarks key
 
|
 
|
 
|-
 
|-
Line 531: Line 573:
 
|escape
 
|escape
 
|Escape key  
 
|Escape key  
|
+
|On Android, this is the on screen back button.
 
|-
 
|-
 
|help
 
|help
Line 560: Line 602:
 
|Currency unit key
 
|Currency unit key
 
|e.g. the Euro (€) key.
 
|e.g. the Euro (€) key.
|
 
 
|-
 
|-
 
|undo
 
|undo
Line 566: Line 607:
 
|
 
|
 
|}
 
|}
 +
 +
== Examples ==
 +
Note how [[love.keypressed]] gives direct key presses, whereas [[love.textinput]] gives the text that key combinations produce.
 +
 +
Let's take the "#" symbol as an example (assuming a U.S. keyboard):
 +
<source lang="lua">
 +
function love.keypressed(key)
 +
    print(key)
 +
end
 +
--> shift
 +
--> 3
 +
 +
function love.textinput(text)
 +
    print(text)
 +
end
 +
--> #
 +
</source>
  
 
== See Also ==
 
== See Also ==
 
* [[parent::love.keyboard]]
 
* [[parent::love.keyboard]]
* [[love.keyboard.isDown]]
 
 
* [[love.keypressed]]
 
* [[love.keypressed]]
 
* [[love.keyreleased]]
 
* [[love.keyreleased]]
 +
* [[love.keyboard.isDown]]
 +
* [[love.keyboard.getScancodeFromKey]]
 +
* [[love.keyboard.getKeyFromScancode]]
 
[[Category:Enums]]
 
[[Category:Enums]]
 
{{#set:Description=All the keys you can press.}}
 
{{#set:Description=All the keys you can press.}}

Latest revision as of 00:18, 23 January 2023

All the keys you can press. Note that some keys may not be available on your keyboard or system.

Constants

Key string Description Note(s)
Character keys
a The A key
b The B key
c The C key
d The D key
e The E key
f The F key
g The G key
h The H key
i The I key
j The J key
k The K key
l The L key
m The M key
n The N key
o The O key
p The P key
q The Q key
r The R key
s The S key
t The T key
u The U key
v The V key
w The W key
x The X key
y The Y key
z The Z key
0 The zero key
1 The one key
2 The two key
3 The three key
4 The four key
5 The five key
6 The six key
7 The seven key
8 The eight key
9 The nine key
space Space key In version 0.9.2 and earlier this is represented by the actual space character ' '.
! Exclamation mark key
" Double quote key
# Hash key
$ Dollar key
& Ampersand key
' Single quote key
( Left parenthesis key
) Right parenthesis key
* Asterisk key
+ Plus key
, Comma key
- Hyphen-minus key
. Full stop key
/ Slash key
: Colon key
; Semicolon key
< Less-than key
= Equal key
> Greater-than key
? Question mark key
@ At sign key
[ Left square bracket key
\ Backslash key
] Right square bracket key
^ Caret key
_ Underscore key
` Grave accent key Also known as the "Back tick" key
Numpad keys
kp0 The numpad zero key
kp1 The numpad one key
kp2 The numpad two key
kp3 The numpad three key
kp4 The numpad four key
kp5 The numpad five key
kp6 The numpad six key
kp7 The numpad seven key
kp8 The numpad eight key
kp9 The numpad nine key
kp. The numpad decimal point key
kp, The numpad comma key
kp/ The numpad division key
kp* The numpad multiplication key
kp- The numpad substraction key
kp+ The numpad addition key
kpenter The numpad enter key
kp= The numpad equals key
Navigation keys
up Up arrow key
down Down arrow key
right Right arrow key
left Left arrow key
home Home key
end End key
pageup Page up key
pagedown Page down key
Editing keys
insert Insert key
backspace Backspace key
tab Tab key
clear Clear key
return Return key Also known as the Enter key
delete Delete key
Function keys
f1 The 1st function key
f2 The 2nd function key
f3 The 3rd function key
f4 The 4th function key
f5 The 5th function key
f6 The 6th function key
f7 The 7th function key
f8 The 8th function key
f9 The 9th function key
f10 The 10th function key
f11 The 11th function key
f12 The 12th function key
f13 The 13th function key
f14 The 14th function key
f15 The 15th function key
f16 The 16th function key
f17 The 17th function key
f18 The 18th function key
Modifier keys
numlock Num-lock key Clear on Mac keyboards.
capslock Caps-lock key
scrolllock Scroll-lock key
rshift Right shift key
lshift Left shift key
rctrl Right control key
lctrl Left control key
ralt Right alt key
lalt Left alt key
rgui Right gui key Command key in OS X, Windows key in Windows.
lgui Left gui key Command key in OS X, Windows key in Windows.
mode Mode key
Application keys
www WWW key
mail Mail key
calculator Calculator key
computer Computer key
appsearch Application search key
apphome Application home key
appback Application back key
appforward Application forward key
apprefresh Application refresh key
appbookmarks Application bookmarks key
Miscellaneous keys
pause Pause key Sends a key release immediately on some platforms, even if held down.
escape Escape key On Android, this is the on screen back button.
help Help key
printscreen Printscreen key Sends a key release immediately on Windows, even if held down.
sysreq System request key
menu Menu key
application Application key Windows contextual menu, compose key.
power Power key
currencyunit Currency unit key e.g. the Euro (€) key.
undo Undo key

Examples

Note how love.keypressed gives direct key presses, whereas love.textinput gives the text that key combinations produce.

Let's take the "#" symbol as an example (assuming a U.S. keyboard):

function love.keypressed(key)
    print(key)
end
--> shift
--> 3

function love.textinput(text)
    print(text)
end
--> #

See Also


Other Languages