Skip to content

Instantly share code, notes, and snippets.

@kubido
Created June 18, 2012 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubido/2946744 to your computer and use it in GitHub Desktop.
Save kubido/2946744 to your computer and use it in GitHub Desktop.
test arrow key
$(document).keydown(function(e){
speed = 3
switch (e.keyCode) {
case 37: // Move Left
$('.dialog').offset({left: $('.dialog').offset().left - speed});
break;
case 39: // Move Right
$('.dialog').offset({left: $('.dialog').offset().left + speed});
break;
case 38: // Move Up
$('.dialog').offset({top: $('.dialog').offset().top - speed});
break;
case 40: // Move Down
$('.dialog').offset({top: $('.dialog').offset().top + speed});
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment