playdate.keyPressed is nil

I am not being able to call the simulator keyboard functions.
Maybe I'm missing an import or something silly, but I can not find what that would be.

Sample main.lua

import "CoreLibs/object"

function playdate.update()
    print(playdate.isSimulator) -- looks good, prints: 1
    printTable(playdate.simulator) -- also looks good, prints: exit, getURL, openURL, writeToFile.

    -- No problem with this.
    if playdate.buttonJustReleased( playdate.kButtonA ) then
        print("A!")
    end

    -- Either of the following checks errors saying the function is nil.
    -- 'playdate' is not nil.
    local gyro_x = 0
    if playdate.keyPressed('j') then
        gyro_x -= 5
    end
    if playdate.keyReleased('l') then
        gyro_x += 5
    end
    print(gyro_x)
end

Error:

main.lua:15: field 'keyPressed' is not callable (a nil value)
stack traceback:
	main.lua:15: in function <main.lua:3>

Running with:
Simulator on macOS Sonoma 14.4
SDK version 2.4.2

Hello, the function needs to be defined (outside the update function), something like this:

function playdate.keyPressed(key)
    if key == "p" then ... end
end

ah, yes! Thank you
I had not understood how it's meant to be used.