Added code to read andsave the state of the keyswitch input