Skip to navigation

Keyboard: ScanKeyboard

Name: ScanKeyboard [Show more] Type: Subroutine Category: Keyboard Summary: Scan the keyboard for a specific key Deep dive: The key logger
Arguments: X The internal key number of the key to scan for
Returns: Z flag If set (BEQ) then the key is being pressed, if clear (BNE) then it is not being pressed
.ScanKeyboard LDA #129 \ Call OSBYTE with A = 129, X = key number and Y = &FF LDY #&FF \ to scan the keyboard for the key in X, returning the JSR OSBYTE \ following in both X and Y: \ \ * 0 = the key is not being pressed \ \ * &FF = the key is being pressed CPX #&FF \ Set the Z flag depending on whether the key is being \ pressed RTS \ Return from the subroutine