JSFiddle - React, Tailwind, and code Playground

by Cori Haws

JavaScript

$(function () {
    var images = [
        'http://www.vogue.co.uk/_/media/prehistoric-trends/raptor1.png',
        'http://www.vogue.co.uk/_/media/prehistoric-trends/raptor2.png',
        'http://www.vogue.co.uk/_/media/prehistoric-trends/raptor3.png',
        'http://www.vogue.co.uk/_/media/prehistoric-trends/raptor4.png',
        'http://www.vogue.co.uk/_/media/prehistoric-trends/raptor5.png',
        'http://www.vogue.co.uk/_/media/prehistoric-trends/raptor6.png',
        'http://www.vogue.co.uk/_/media/prehistoric-trends/raptor7.png'];
    var index = 0;
    $(document).on('keypress', function (event) {
        var c = String.fromCharCode(event.charCode);
        if(c === 'a') {
            var image = images[index];
            console.log(image);
            index = Math.floor((Math.random()*6)+1);
            
            $('<img style="position: fixed; bottom: 0; right: 0" src="' + image + '"/>').appendTo(document.body).animate({right: '200%'}, 2000, function() {
                $(this).remove();
            });
        }
    })
});