Skip to main content

keyboard-bashing.js (Source)

javascript:(function(){
    b=document.body;
    b.innerHTML = '';
    document.head.innerHTML = '';
    s=document.createElement('style');
    document.head.appendChild(s);
    s.textContent = `
    body {
        padding: 0;
        margin: 0;
        transition:background-color 1s, color 1s;
    }
    textarea {
        border: none;
        width:100vw;
        height:100vh;
        font-size:15vh;
        resize:none;
        padding:1em;
        background: none;
     }
     textarea:focus {
        outline: none;
     }
     body.hit {
        animation: wobble 0.1s;
     }
     @keyframes wobble {
        0% { transform: rotate(-1deg); }
        100% { transform: rotate(0deg); }
    }
    `;
    t = document.createElement('textarea');
    document.body.appendChild(t);
    f = () => {
        t.style['color']=`hsl(${Math.random()*360},50%,20%)`;
        b.style['backgroundColor']=`hsl(${Math.random()*360},50%,90%)`;
        document.body.classList.add('hit');
        setTimeout(()=>document.body.classList.remove('hit'),200)
    };
    t.addEventListener('keypress',f)
}())