../
kernel
functions
add
all
apply_delta
assert
atan2
btn
btnp
camera
cd
char
chooser
circ
circfill
clip
cls
color
cos
count
cp
create_delta
create_gui
create_process
cursor
date
del
deli
env
error
exit
fetch
fetch_metadata
fget
fillp
foreach
fset
fstat
fullpath
get_clipboard
get_display
get_draw_target
get_spr
include
input
key
keyp
line
ls
map
max
memcpy
memmap
memset
menuitem
mget
mkdir
mouse
mouselock
mset
music
mv
note
on_event
open
oval
ovalfill
peek
peek2
peek4
peek8
peektext
pget
pid
pod
poke
poke2
poke4
poke8
printh
pset
pwd
readtext
rect
rectfill
rm
rrect
rrectfill
scoresub
send_message
set_clipboard
set_draw_target
set_spr
sfx
sin
socket
split
spr
sspr
stat
stop
store
store_metadata
sub
time
tokenoid
type
unmap
unpod
userdata
vec
vid
window
key(k,[raw])
Overview
key queries the key state of a keyboard key.
By default, key() uses the local keyboard layout; On an AZERTY keyboard, key("a") is true when the key to the right of Tab is pressed.
You can use the raw layout by setting [raw] to true and using k as a raw scancode.
To get the raw layout, use true as the second parameter to indicate that k should be the name of the raw scancode.
For keyboard key presses, use keyp.
For controller inputs, use btn.
Arguments
k: string
The name of each key is the same as the character it produces on a US keyboard with some exceptions: "space", "delete", "enter", "tab", "ctrl", "shift", "alt", "pageup", "pagedown".
When [raw] is not true
The key to query the state of.
When [raw] is true
The raw scancode to query the state of
[raw]: boolean
Whether or not k is a raw scancode.
Returns
down: boolean
Returns true when the requested key is down, false otherwise.
Examples
Sourced from the Picotron Manual
Whether the key to the right of CAPSLOCK is held, regardless of local keyboard layout.
?key("a", true)
Keybind example
if (key"ctrl" and keyp"a") printh("CTRL-A Pressed")
function _draw()
cls(1)
-- draw when either shift key is held down
if (key("shift")) circfill(100,100,40,12)
end
key()
Overview
Returns true when any key is down.
Returns
down: boolean
Returns true when any key is down, false otherwise.