Reputation: 99
Is it possible to make a shooting gif appear when click in Ctrl key in JavaScript ?
Thanks
I only have the click event:
document.addEventListener('keydown', function(event){
if(event.keyCode == 17) {
document.getElementById("key").innerHTML = "Ctrl - Shoot";
}
Upvotes: 0
Views: 31
Reputation: 75062
Maybe possible, if your or your client's browser supports gif rendering.
Why not just put a image?
document.addEventListener('keydown', function(event){
if(event.keyCode == 17) {
document.getElementById("key").innerHTML = "<img src=\"shooting.gif\">";
}
});
You should also set width
, height
and alt
properties to img
tag.
Upvotes: 1