JSFiddle - React, Tailwind, and code Playground
by João Vitor Scheuermann
HTML
<link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet">
<span id="key" class="value">KEY</span>
<span>:</span>
<span id="keyCode" class="value">CODE</span>
SCSS
* {
margin: 0;
padding: 0;
}
html, body {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: #000000;
font-family: 'Anton';
font-size: 30px;
color: #ffffff;
letter-spacing: 1px;
span {
margin: 0 0 0 5px;
}
}
JavaScript
const key = document.querySelector('#key')
const keyCode = document.querySelector('#keyCode')
window.addEventListener('keydown', e => {
console.log(e)
key.innerHTML = e.key
keyCode.innerHTML = e.keyCode
})