SUB_SCAN: KEY = READ_KEY(KEY_SCAN) IF KEY_SCAN = KEY_MAX THEN KEY_SCAN =0 KEY_SCAN = KEY_SCAN + 1
ON STATUS GOTO ST_1, ST_2, ST_3 ST_0: IF KEY <> 0 THEN KEY_CODE = KEY KEY_DELAY = (KEY_MAX + 2) STATUS = 1 END IF EXIT SUB
ST_1: IF KEY = KEY_CODE THEN KEY_DELAY = KEY_DELAY + KEY_MAX IF KEY_DELAY>(KEY_MAX + 10) THEN F_KEY_PRESS = TRUE STATUS = 2 END IF ELSE KEY_DELAY = KEY_DELAY - 1 IF KEY_DELAY=0 THEN STATUS =0 END IF EXIT SUB
ST_2: KEY_DELAY=KEY_DELAY-1 IF KEY_DELAY=0 THEN STATUS =3 END IF EXIT SUB
ST_3: IF NOT F_KEY_PRESS THEN KEY_CODE = 0 STATUS =0 END IF END SUB