     key-s keys nth [ player walk-backward ] when 
     key-a keys nth [ player walk-leftward ] when 
     key-d keys nth [ player walk-rightward ] when 
+    key-left-arrow keys nth [ player -1 look-horizontally ] when 
+    key-right-arrow keys nth [ player 1 look-horizontally ] when 
+    key-down-arrow keys nth [ player -1 look-vertically ] when 
+    key-up-arrow keys nth [ player 1 look-vertically ] when 
     key-space keys nth [ player jump ] when 
     key-escape keys nth [ world close-window ] when
     player read-mouse rotate-with-mouse


: forward-vector ( player -- v )
    yaw>> 0.0
    { 0.0 0.0 $ MOVEMENT-SPEED } vneg eye-rotate ;
: rightward-vector ( player -- v )
    yaw>> 0.0
    { $ MOVEMENT-SPEED 0.0 0.0 } eye-rotate ;

: walk-forward ( player -- )
    dup forward-vector [ v+ ] curry change-velocity drop ;

: walk-rightward ( player -- )
    dup rightward-vector [ v+ ] curry change-velocity drop ;
: jump ( player -- )
    [ ${ 0.0 JUMP 0.0 } v+ ] change-velocity drop ;
: rotate-leftward ( player x -- )
    [ - ] curry change-yaw drop ;
: rotate-rightward ( player x -- )
    [ + ] curry change-yaw drop ;
: look-horizontally ( player x -- )
    [ + ] curry change-yaw drop ;
: look-vertically ( player x -- )
    [ - clamp-pitch ] curry change-pitch drop ;


: rotate-with-mouse ( player mouse -- )
    [ dx>> MOUSE-SCALE * look-horizontally ]
    [ dy>> MOUSE-SCALE * look-vertically ] 2bi ;

:: handle-input ( world -- )
    world player>> :> player
