@@ -19,12 +19,12 @@ export const keyboard = function(motors) {
1919 e . preventRepeat ( ) ;
2020 console . log ( "[keyboard] UP" ) ;
2121 intervalUp = setInterval ( function ( ) {
22- if ( speed <= SPEED_MAX ) {
23-
24- motors . set ( speed , motors . direction . forward ) ;
22+ if ( speed < SPEED_MAX ) {
2523 console . log ( '[keyboard]' , speed ) ;
2624 speed = speed + SPEED_STEP ;
2725 }
26+ motors . set ( speed , motors . direction . forward ) ;
27+
2828 } , UPDATE_INTERVAL ) ;
2929 } , function ( e ) {
3030 clearInterval ( intervalUp ) ;
@@ -37,12 +37,12 @@ export const keyboard = function(motors) {
3737 e . preventRepeat ( ) ;
3838 console . log ( "[keyboard] DOWN" ) ;
3939 intervalDown = setInterval ( function ( ) {
40- if ( speed <= SPEED_MAX ) {
41-
42- motors . set ( speed , motors . direction . backward ) ;
40+ if ( speed < SPEED_MAX ) {
4341 console . log ( '[keyboard]' , speed ) ;
4442 speed = speed + SPEED_STEP ;
4543 }
44+ motors . set ( speed , motors . direction . backward ) ;
45+
4646 } , UPDATE_INTERVAL ) ;
4747
4848 } , function ( e ) {
@@ -56,12 +56,12 @@ export const keyboard = function(motors) {
5656 e . preventRepeat ( ) ;
5757 console . log ( "[keyboard] LEFT" ) ;
5858 intervalLeft = setInterval ( function ( ) {
59- if ( speed <= SPEED_MAX ) {
60-
61- motors . set ( speed , motors . direction . left ) ;
59+ if ( speed < SPEED_MAX ) {
6260 console . log ( '[keyboard]' , speed ) ;
6361 speed = speed + SPEED_STEP ;
6462 }
63+ motors . set ( speed , motors . direction . left ) ;
64+
6565 } , UPDATE_INTERVAL ) ;
6666
6767 } , function ( e ) {
@@ -75,12 +75,12 @@ export const keyboard = function(motors) {
7575 e . preventRepeat ( ) ;
7676 console . log ( "[keyboard] RIGHT" ) ;
7777 intervalRight = setInterval ( function ( ) {
78- if ( speed <= SPEED_MAX ) {
79-
80- motors . set ( speed , motors . direction . right ) ;
78+ if ( speed < SPEED_MAX ) {
8179 console . log ( '[keyboard]' , speed ) ;
8280 speed = speed + SPEED_STEP ;
8381 }
82+ motors . set ( speed , motors . direction . right ) ;
83+
8484 } , UPDATE_INTERVAL ) ;
8585
8686 } , function ( e ) {
0 commit comments