simplify scan code processing
use symbolic names for keyboard scan states
remove unnecessary temporary variable
move keyboard scan state variables into interrupt handler
refactor serial IO functionality