JSFiddle - React, Tailwind, and code Playground

HTML

<section class="container">
    <div id="box" class="show-top-2">
        <figure class="front">1</figure>
        <figure class="back">2</figure>
        <figure class="right">3</figure>
        <figure class="left">4</figure>
        <figure class="top">5</figure>
        <figure class="bottom">6</figure>
    </div>
</section>

CSS

.container {
    width: 150px;
    height: 100px;
    position: relative;
    margin: 25px auto 25px auto;
    perspective: 600px;
}

#box {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    animation-duration: 1s;
    -webkit-animation-duration: 1s;
    -moz-animation-duration: 1s;
}

#box figure {
    display: block;
    position: absolute;
    border: 1px solid black;
    line-height: 98px;
    font-size: 45px;
    text-align: center;
    font-weight: bold;
    color: white;
}

figure {
    margin: 0;
}

#box .front,
#box .back {
    width: 148px;
    height: 98px;
}

#box .right,
#box .left {
    width: 48px;
    height: 98px;
    left: 50px;
}

#box .top,
#box .bottom {
    width: 148px;
    height: 48px;
    top: 25px;
    line-height: 48px;
}

#box .front {
    background: hsla(000, 100%, 50%, 0.7);
}

#box .back {
    background: hsla(160, 100%, 50%, 0.7);
}

#box .right {
    background: hsla(120, 100%, 50%, 0.7);
}

#box .left {
    background: hsla(180, 100%, 50%, 0.7);
}

#box .top {
    background: hsla(240, 100%, 50%, 0.7);
}

#box .bottom {
    background: hsla(300, 100%, 50%, 0.7);
}

#box .front {
    transform: translateZ(25px);	
}

#box .back {
    transform: rotateY(180deg) translateZ(25px);
}

#box .right {
    transform: rotateY(90deg) translateZ(75px);
}

#box .left {
    transform: rotateY(-90deg) translateZ(75px);
}

#box .top {
    transform: rotateX(90deg) translateZ(50px);
}

#box .bottom {
    transform: rotateX(-90deg) translateZ(50px);
}

@-webkit-keyframes top-2-back-4 {
	from { transform: translateZ(-100px) rotateX(270deg) rotateY(-90deg); }
	to { transform: translateZ(-50px) rotateX(270deg) rotateY(-90deg) rotateX(-90deg); }
}

@keyframes top-2-back-4 {
	from { transform: translateZ(-100px) rotateX(270deg) rotateY(-90deg); }
	to { transform: translateZ(-50px) rotateX(270deg) rotateY(-90deg) rotateX(-90deg); }
}

#box.top-2-back-4 {
	animation-name:...

JavaScript

$('document').ready(function() {

    var position = 'show-top-2';
    
    $(window).bind('keyup', function(event) {
        switch (event.keyCode) {
            case 37: // left
                if (position == 'show-top-2') {
                    $('#box').removeClass().addClass('top-2-back-4 show-back-4');
                    position = 'show-back-4';
                }
                break;
        }
    });
    
});