range checking for keyboard manipulation