-
-
Notifications
You must be signed in to change notification settings - Fork 492
btnp
##btnp btnp [id: 0..5 8..13 [hold period] ] -> pressed (but wasn't pressed in previous frame)
##Parameters:
id : the id of the key we need to interrogate, see the key map for reference
hold period : the duration the key must be kept pressed to return another true value. Useful in scrolling menu items.
##Description:
This function allow to read the status of one of the buttons attached to the TIC.
The function report a true value only in the moment the key is pressed.
It can be used also with a period parameter that allow to return a true value while keeping the key pressed, after the period is elapsed.
##Example:
-- btnp demo: move the rectangle in 10 pixels step,
-- every time one direction keys is pressed
x=120
y=80
cls(12)
function TIC()
if btnp(0) then y=y-10 end
if btnp(1) then y=y+10 end
if btnp(2) then x=x-10 end
if btnp(3) then x=x+10 end
rect(x,y,10,10,8)
end
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
Platform
RAM & VRAM | Display | Palette | Bits per Pixel (BPP) |
.tic
Format | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
- BDR (0.90)
- BOOT (1.0)
- MENU
- OVR (deprecated)
- SCN (deprecated)
- TIC
- btn & btnp
- circ & circb
- clip
- cls
- elli & ellib (0.90)
- exit
- fget & fset (0.80)
- font
- key & keyp
- line
- map
- memcpy & memset
- mget & mset
- mouse
- music
- peek, peek4
- peek1, peek2 (1.0)
- pix
- pmem
- poke, poke4
- poke1, poke2 (1.0)
- rect & rectb
- reset
- sfx
- spr
- sync
- ttri (1.0)
- time
- trace
- tri & trib (0.90)
- tstamp (0.80)
- vbank (1.0)