$(document).ready(function()
{
$(document).keydown(function(key)
{
switch (parseInt(key.which, 10))
{
// Left arrow key pressed
case 37:
$('img').animate(
{
left: "-=10px"
}, 'fast');
break;
// Up Arrow Pressed
case 38:
$('img').animate(
{
top: "-=10px"
}, 'fast');
break;
// Right Arrow Pressed
case 39:
$('img').animate(
{
left: "+=10px"
}, 'fast');
break;
// Down Arrow Pressed
case 40:
$('img').animate(
{
top: "+=10px"
}, 'fast');
break;
}
});
});Note: HTML, CSS & Javascript codes are there in the attachment.
