detect the type of keypress