added method for checking keypresses