Can’t you simplify the key handler quite a bit? Less calls to KEYDOWN might improve performance.
From:
'a
IF _KEYDOWN(97) AND key97 = false THEN
key97 = _KEYDOWN(97)
END IF
IF NOT _KEYDOWN(97) AND key97 <> false THEN
key97 = false
END IF
To:
IF _KEYDOWN(97) THEN key97 = true ELSE key97 = false ‘a
One simple check to set if it’s down or not.
It's maybe slightly (but not much) better...
Normaly I use something like
IF _KEYDOWN(KEYCODE~%(keyA)) AND controlinput.key(keyA) = false THEN
controlinput.key(keyA) = true
ELSEIF NOT _KEYDOWN(KEYCODE~%(keyA)) AND controlinput.key(keyA) THEN
controlinput.key(keyA) = false
END IF
as the keyhandle, because sometimes I need to lock a key while pressing, to only do a specific action just one time.
Now I followed your sugestion but it doesn't change much.