Is there an easy way to check if any button is down?

I'd like to be able to check if any button is down without having to check each one individually. I couldn't find anything in the docs. My game is primarily played with the crank and I'd like to be able to take an action when any button is pressed (and the action can vary so having to check each button all over the place seems yucky).

I haven't tried this and I doubt I have it quite right... but how about this approach?

local current, pressed, released = playdate.getButtonState()
if current ~= nil then
     --Some buttons are currently down

getButtonState docs

(I haven't done anything with "bitmasks" in Lua... maybe the "nil" test isn't right?)

It looks like it is 0 when nothing is pressed so I can just check if it's anything else. Thanks for the idea!

1 Like