OK, here is the updated, and working code. Making the image relative did the trick. Now the only thing left is as soon as I remove my finger from the key, I want the image to stop moving. How would I properly use the keyup?
<html>
<head></head>
<body>
<img id="pic" src="run0.png" alt="image" height="100" width="100" style="position: relative;"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).keydown(function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '39'){
$("#pic").animate({
left: '+=10px',
});
}
});
</script>
</body>
</html>
I would also prefer no to have to put an image on the document first with HTML, but to just append it to the document from Javascript/jQuery. And if anyone can help me do it with pure Javascript that would be appreciated.