added utility function to assist with keypress detection