Skip to navigation


Keyboard: ScanKeyboard

Name: ScanKeyboard [Show more] Type: Subroutine Category: Keyboard Summary: Scan the keyboard for a specific key press
Arguments: X The negative inkey value of the key to scan for (in the range &80 to &FF)
Returns: Z flag The result: * Set if the key in X is being pressed, in which case BEQ will branch * Clear if the key in X is not being pressed, in which case BNE will branch
Other entry points: ScanKeyboard-1 Contains an RTS
.ScanKeyboard LDA #129 \ Call OSBYTE with A = 129, Y = &FF and the inkey value LDY #&FF \ in X, to scan the keyboard for key X JSR OSBYTE CPX #&FF \ If the key in X is being pressed, the above call sets \ both X and Y to &FF, so this sets the Z flag depending \ on whether the key is being pressed (so a BEQ after \ the call will branch if the key in X is being pressed) RTS \ Return from the subroutine