Replaced all keyboard state variables and queries with global keystates variable for consistency.
Fixed a variable shadowing bug.