Skip to content

Add btnr and keyr API and tests - #3112

Merged
nesbox merged 2 commits into
nesbox:mainfrom
swoolcock:btnr
Oct 24, 2026
Merged

nesbox merged 2 commits into
nesbox:mainfrom
swoolcock:btnr

Conversation

@swoolcock

Copy link
Copy Markdown
Collaborator

Implements btnr() which functions similarly to btnp(), except it returns true when the button is not down but it was down on the previous frame (inverse logic to btnp()). Similar for keyr() vs keyp().

Resolves #3095

Example:

color = 13
function TIC()
    if btnp(4) then color = color + 1 end
    if btnr(4) then color = color - 1 end
    cls(color)
end

Pressing the first action button will increase color to 14, then releasing the button will decrease it back to 13. This shows that the button hold state btn() is not considered and only the press/release frames are relevant.

Similar happens with keyp() and keyr().

@swoolcock

Copy link
Copy Markdown
Collaborator Author

@nesbox would you mind rerunning this workflow? I think something went wrong that's not related to my change and would be fine with a rerun.
Alternatively if you're okay with it could you give me permission to trigger actions with workflow_dispatch? <3

@nesbox
nesbox merged commit 3f805c1 into nesbox:main Oct 24, 2026
32 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

btnr (and keyr)

2 participants