../
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
keyp(k,[raw])
Overview
keyp queries wheter a keyboard key is pressed.
By default, keyp() uses the local keyboard layout; On an AZERTY keyboard, keyp("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.
This is typically used in menus or grid-based player movement.
The state that keyp() reads is reset at the start of each call to _update(), so it is preferable to use keyp only from inside that call and not from _draw(), which might be called less frequently.
For keyboard state, use key.
For controller button presses, use btnp.
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 whether it's pressed or not.
When [raw] is true
The raw scancode whether it's pressed or not.
[raw]: boolean
Whether or not k is a raw scancode.
Returns
pressed: boolean
Returns true when the requested key is pressed, false otherwise.
Examples
Sourced from the Picotron Manual
Whether the key to the right of CAPSLOCK is pressed, regardless of local keyboard layout.
?keyp("a", true)
Keybind example
if (key"ctrl" and keyp"a") printh("CTRL-A Pressed")
keyp()
Overview
Returns true when any key is pressed.
Returns
down: boolean
Returns true when any key is pressed, false otherwise.