added extra contstraints for keypress