JSFiddle - React, Tailwind, and code Playground

by dirkk0

HTML

<img id="pic" src ="https://68.media.tumblr.com/avatar_fde62a40f018_128.png">

JavaScript

document.onkeydown = checkKey;

function checkKey(e) {

    e = e || window.event;

    if (e.keyCode == '38') {
        // up arrow
    }
    else if (e.keyCode == '40') {
        // down arrow
    }
    else if (e.keyCode == '37') {
       // left arrow
       document.getElementById('pic').style.display = "None";
    }
    else if (e.keyCode == '39') {
       // right arrow
       document.getElementById('pic').style.display = "Block";
    }

}