question: public static Direction directionForArrowKey ( KeyEvent e ) { int index = Math . max ( 0 , Math . min ( e . getKeyCode ( ) , KeyEvent . VK_DOWN ) - KeyEvent . VK_LEFT ) ; return Direction . values ( ) [ index ] ; }
target:  Returns a direction corresponding to the specified arrow key. If the event does not map to one of the 4 keyboard arrows, the returned direction will be either left or down.