Change speed through keydown at the spriteanimation-plugin spritley

Change speed through keydown at the spriteanimation-plugin spritley

Hi,
i´m using the spriteanimation plugin spritley .
And now I want to change the .sprite({ speed: 4000}); through the arrowkeys, left and right using keydown.
But I have some problems with the syntax.


Could somebody take a look and can tell me how can I fix this?


  1. var player = $('#draisine');
  2. player.sprite({fps: 30, no_of_frames: 1, speed: 4000});
  3.       
  4.     //Draisine keydowns  
  5. $(document).keydown(function(e){
  6. switch (e.which) {
  7. /*case 40: //down
  8. player.animate({
  9. top: "+=80"
  10. });
  11. break;*/
  12. case 38: //up
  13. player.animate({
  14. top: "-=80"
  15. }).animate({
  16. top: "+=80"
  17. });
  18. break;
  19. case 37: //left
  20. player.sprite({
  21.               speed: -= 1000; 
  22.               if (speed < 1000) {
  23.                 speed = 1000;
  24.               }
  25. });
  26. break;
  27. case 39: //right
  28. player.sprite({
  29.               speed: -= 1000;
  30.               if (speed < 1000) {
  31.                 speed = 1000;
  32.               }
  33.             });
  34. break;
  35. case 32: //space
  36. player.animate({
  37. top: "-=80"
  38. }).animate({
  39. top: "+=80"
  40. }); 
  41. }      
  42. });