JSFiddle - React, Tailwind, and code Playground

by grantgibson

HTML

<div id="kb">
</div>

CSS

#kb {
    font-family: Arial, Helvetica;
    background-color: #999;
}
.keyRow {
    text-align: center;
}
.key {
    display: inline-block;
    font-size: 1em;
    width: 2em;
    height: 2em;
    line-height: 2em;
    border: 1px solid #999;
    text-align: center;
    margin: 5px;
    text-transform: uppercase;
    box-shadow: 0px 0px 5px #666;
    border-radius: 3px;
    background-color: #fff;
}

JavaScript

var kbContents = "";
var kbLayout = [ ["q","w","e","r","t","y","u","i","o","p"] , 
                 ["a","s","d","f","g","h","j","k","l"],
                 ["z","x","c","v","b","n","m","<"] ];

for (r=0; r < kbLayout.length; r++) {
    kbContents += "<div class='keyRow'>";
    for (c=0; c < kbLayout[r].length; c++) {
        kbContents += "<div class='key'>" + kbLayout[r][c] + "</div>";
    }
    kbContents += "</div>";
}
$("#kb").append(kbContents);
$(".key").click(function() {
    alert("Clicked " + $(this).html() );
});