set state to 0 before clearing key