Log In  

So, I'm working on a toy musical keyboard program, and I want to use SDL scancodes to detect which keys are being held - but I know that PICO-8 will pause if you hit the "P" key (whatever key that happens to be in the user's keyboard layout). So I want to detect when a "P" input is being received and stop it...

...but my current code:

--interrupt pause on P
while stat(30) do
    if stat(31)=="p" or "◆" then
        --suppress pause

only works for the initial press - when the key starts repeating, stat(30) doesn't detect the input but PICO-8 pauses anyway.

Any suggestions? I'd rather not interrupt all pause inputs - that makes things difficult for Splore users.

Edit: Apologies to @dw817, whose explanations I apparently completely failed to parse: in the changelog for 0.2.2b it is noted that holding the pause button will always bring up the hardware pause menu, even when pause would otherwise be suppressed. This rules out any solution that involves the player holding down P that I can implement as cart programmer. (Shoutout to @cubee's description of a related bug which cued me in.)

P#117088 2022-09-08 21:20 ( Edited 2022-09-10 12:35)


Was just testing this, @packbat.

function _init()

function _update()
  if k>"" then
    ?"you hit "..k

Yep, it can't be helped. I suspect this is in place to ensure that PAUSE CAN BE ENACTED even if the coder wants "P."

It will work for a tap, yes, but hold it down and you will always get the menu.

Suggest @zep add a new memory location to reroute system keys.

For instance:


This would reroute key "P" to Spacebar.

P#117092 2022-09-08 22:37 ( Edited 2022-09-08 22:45)

Honestly, if we're asking zep for changes, I'd just want the repeating Ps to show up in stat(30).

P#117094 2022-09-08 22:46

...just had an idea to test: check for the other pause keys, and if neither shows up, then cancel pause whether P was hit or not.

Edit: Wow - okay, so I tried it:

--suppress pause for P
--(i.e. not Enter or Esc)
local pause=false
while stat(30) do
    if stat(31)=="\r" or stat(31)=="\27" then
        --allow pause
if pause then

and it stopped the pause on initial P-press, but not on repeat. And yes, I did a poke(0x5f5c,255) to disable button repeat.

Which means that the poke(0x5f30,1) happened on the frame where it paused and PICO-8 paused anyway.

Is it hard-coded that holding P will pause PICO-8?

P#117095 2022-09-08 23:00 ( Edited 2022-09-08 23:21)

Hi @packbat.

The poke(0x5f5c,255) only affects the joystick keys. Not the keyboard, like the letter "P."

Currently there is no way to change the repeat wait time or repeat speed of the regular keyboard in Pico-8.

P#117098 2022-09-08 23:51

Belatedly: @dw817's suggestion of assigning key configs to memory locations would actually be amazing for accessibility - players being able to reassign keys and buttons is a big contributor to disabled players being able to construct key layouts that work for them, and making it accessible via @ and poke() would let cart programmers build their own tools for it.

Edit: That, or building a keybind tool into PICO-8's hardware pause menu - although that wouldn't support cart-specific key rebinds (unless it does).

P#117140 2022-09-10 12:39 ( Edited 2022-09-10 12:40)

[Please log in to post a comment]