JSFiddle - React, Tailwind, and code Playground
HTML
<input type="button" class="UpKeyImage" id="Up" value="Up" />
CSS
.UpKeyImage {
/*this will hide the value*/
text-indent: -999em;
overflow: hidden;
text-align: left;
/*Downside of this solution, you will ned to define the width and height*/
width: 400px;
height: 200px;
/*this will be dancerup.png*/
background-image: url(http://lorempixel.com/400/200/);
border: none;
background-color: transparent;
box-shadow: none;
}
.UpKeyImage.dance-up {
/* path to the other image */
background-image: url(http://lorempixel.com/sports/400/200/);
}
JavaScript
$(function () {
$('#Up')
.mouseup(function () {
$(this).removeClass("dance-up");
})
.mouseleave(function () {
$(this).removeClass("dance-up");
})
.mousedown(function () {
$(this).addClass("dance-up");
});
});