var api = api || {};  //!< @namespace api

/**
 * Configuration
 */
api.fps = 60;
api.KEYPRESS_TIME = 1000 / api.fps;

/**
 * Get obstacles information.
 * @return a list of obstacles
 */
api.getObstacles = function(){
  var obs = [];
  for (var i in runner.horizon.obstacles){
    var obstacle = runner.horizon.obstacles[i];
    var ob = {};
    for (var key in obstacle)
      ob[key] = obstacle[key];
    obs.push(ob);
  }
  return obs;
}

/**
 * Get player(tRex) information.
 * @return a dict of obstacles
 */
api.getPlayer = function(){
  var player = {};
  var tRex = runner.tRex;
  for (var key in tRex)
    player[key] = tRex[key];
  return player;
}

/**
 * Get currentSpeed.
 * @return a number
 */
api.getCurrentSpeed = function(){
  return runner.currentSpeed;
}

/**
 * Check if game is paused
 * @return a boolean
 */
api.isPaused = function(){
  return runner.paused;
}

/**
 * Get keycode
 * @param {keycode name}, like 'JUMP', 'DUCK'
 */
api.getKeycode = function(type){
  for (var keycode in Runner.keycodes[type])
    return keycode;
}

/**
 * Jump
 */
api.jump = function(){
  Keyboard.keydown(this.getKeycode('JUMP'));
}

/**
 * Duck
 */
api.duck = function(){
  Keyboard.keydown(this.getKeycode('DUCK'));
}

/**
 * Start Ducking
 */
api.duckStart = function(){
  clearInterval(this.speedDropIntervalId);
  this.duckIntervalId = setInterval("api.duck()", this.KEYPRESS_TIME);
}

/**
 * Stop Ducking
 */
api.duckStop = function(){
  clearInterval(this.duckIntervalId);
  Keyboard.keyup(this.getKeycode('DUCK'));
}

/**
 * Checking if not JUMPING
 */
api.speedDropHandler = function(){
  if (this.getPlayer().status != 'JUMPING'){
    Keyboard.keyup(this.getKeycode('DUCK'));
    clearInterval(this.speedDropIntervalId);
  }
}

/**
 * Start Speed Droping
 */
api.speedDrop = function(){
  Keyboard.keydown(this.getKeycode('DUCK'));
  clearInterval(this.speedDropIntervalId);
  this.speedDropIntervalId = setInterval("api.speedDropHandler()", this.KEYPRESS_TIME);
}

/**
 * Check if game is paused, then play it
 */
api.keepPlay = function(){
  if (runner.paused)
    runner.play();
}
@@ -110,16 +110,42 @@
 api.fps;
+%0Aapi.speedDroping = false;
 %0A%0A/**%0A *
@@ -1107,32 +1107,78 @@
 p = function()%7B%0A
+  if (this.getPlayer().status != 'JUMPING')%0A  
   Keyboard.keydo
@@ -1806,20 +1806,51 @@
 valId);%0A
+    this.speedDroping = false;%0A
   %7D%0A
-
 %7D%0A%0A/**%0A 
@@ -1909,91 +1909,113 @@
 %7B%0A  
-Keyboard.keydown(this.getKeycode('DUCK'));%0A  clearInterval(this.speedDropIntervalId
+if (this.speedDroping)%0A    return;%0A  this.speedDroping = true;%0A  Keyboard.keydown(this.getKeycode('DUCK')
 );%0A 

Fix bug: Problems of calling speedDrop over than twice