' Key Polling — INKEY$ and WAITKEY$ demonstration
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL k AS STRING

    PRINT "INKEY$ demo — Press keys (ESC to stop):"
    DO
        k = INKEY$
        IF k <> "" THEN
            PRINT "Key pressed: " + k + "  (ASCII: " + STR$(ASC(k)) + ")"
        END IF
        SLEEP 50
    LOOP UNTIL k = CHR$(27)

    PRINT
    PRINT "WAITKEY$ demo — Press any key..."
    k = WAITKEY$
    PRINT "You pressed: " + k + " (ASCII: " + STR$(ASC(k)) + ")"

    FUNCTION = 0
END FUNCTION
