Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="flag"></div>
<br>
<div class="container">
  <div class="cheatsheet">
    <!--

    <div class="guide">
      <div class="key">
        AltGr
      </div>
      <div class="operator">+</div>
      <div class="key num dual">
        /<br>7 &nbsp {
      </div>
      <div class="operator">=</div>
      <div class="result">{</div>
    </div>
    <div class="guide">
      <div class="key">
        AltGr
      </div>
      <div class="operator">+</div>
      <div class="key num dual">
        =<br>0 &nbsp }
      </div>
      <div class="operator">=</div>
      <div class="result">}</div>

    </div>
    -->

  </div>

  <div class="keyboard">

    <div class="section-a">
    <div class="key function space1">
      Esc
    </div>

    <div class="key function">
      F1
    </div>
    <div class="key function">
      F2
    </div>
    <div class="key function">
      F3
    </div>

    <div class="key function space2">
      F4
    </div>
    <div class="key function">
      F5
    </div>
    <div class="key function">
      F6
    </div>
      <div class="key function">
      F7
    </div>
    <div class="key function space2">
      F8
    </div>

    <div class="key function">
      F9
    </div>
    <div class="key function">
      F10
    </div>
      <div class="key function">
      F11
    </div>
    <div class="key function">
      F12
    </div>
      <!--END FUNCTION KEYS -->

    <div class="key num dual">
      §<br>½
    </div>

    <div id="one" class="key num dual">
      !<br>1
    </div>
    <div id="two" class="key num dual">
      "<br>2 @
    </div>
    <div id="three" class="key num dual">
      #<br>3 &nbsp £
    </div>
    <div id="four" class="key num dual">
      ¤<br>4 &nbsp $
    </div>
    <div id="five" class="key num dual">
      %<br>5 &nbsp €
    </div>
    <div id="six" class="key num dual">
      &<br>6 
    </div>
    <div id="seven" class="key num dual">
      /<br>7 &nbsp {
    </div>
    <div id="eight" class="key num dual">
      (<br>8 &nbsp [
    </div>
    <div id="nine" class="key num dual">
      )<br>9 &nbsp ]
    </div>
    <div id="zero" class="key num dual">
      =<br>0 &nbsp }
    </div>
    <div id="plus" class="key num dual">
      ?<br>+
    </div>
    <div class="key num dual">
      `<br>´ &nbsp |
    </div>
    <div class="key backspace">
        Backspace
    </div>
     <!--END NUMBER KEYS -->

    <div id="tab" class="key tab">
      Tab <->
    </div>

    <div  id="q" class="key letter">
      Q
    </div>
    <div  id="w" class="key letter">
      W
    </div>
    <div  id="e" class="key letter">
      E
    </div>
    <div id="r" class="key letter">
      R
    </div>
    <div id="t" class="key letter">
      T
    </div>
    <div id="y" class="key letter">
      Y
    </div>
    <div id="u" class="key letter">
      U
    </div>
    <div id="i" class="key letter">
      I
    </div>
    <div id="o" class="key letter">
      O
    </div>
    <div id="p" class="key letter">
      P
    </div>
    <div id="å" class="key letter">
      Å
    </div>
    <div id="umlaut" class="key dual">
      ^<br>¨ &nbsp ~
    </div>
    <div class="key letter dual slash">

    </div>
    <div class="key caps">
      Caps<br>Lock
    </div>
    <div id="a" class="key letter">
      A
    </div>
    <div id="s" class="key letter">
      S
    </div>
    <div id="d" class="key letter">
      D
    </div>
    <div id="f" class="key letter">
      F
    </div>
    <div id="g" class="key letter">
      G
    </div>
    <div id="h" class="key letter">
      H
    </div>
    <div id="j" class="key letter">
      J
    </div>
    <div id="k" class="key letter">
      K
    </div>
    <div id="l" class="key letter">
      L
    </div>
    <div id="æ" class="key letter">
      Æ<br>
    </div>
    <div id="ø" class="key letter">
      Ø
    </div>
    <div id="tick" class="key dual">
      *<br>'
    </div>
    <div id="enter" class="key enter">
      Enter
    </div>

    <div id="shift" class="key shift left">
      Shift
    </div>
    <div id="less" class="key dual">
      ><br>< &nbsp \
    </div>
    <div id="z" class="key letter">
      Z
    </div>  
    <div id="x" class="key letter">
      X
    </div>
    <div id="c" class="key letter">
      C
    </div>
    <div id="v" class="key letter">
      V
    </div>
    <div id="b" class="key letter">
      B
    </div>
    <div id="n" class="key letter">
      N
    </div>
    <div id="m" class="key letter">
      M
    </div>
    <div id="comma" class="key dual">
      ; <br>,
    </div>
    <div id="dot" class="key dual">
      :<br>.
    </div>
    <div id="dash" class="key dual">
      _<br>-
    </div>
    <div id="shift-right" class="key shift right">
      Shift
    </div>
    <div class="key ctrl">
      Ctrl
    </div>
    <div id="super" class="key">
      &hearts;
    </div>
    <div id="alt" class="key">
      Alt
    </div>
    <div class="key space">
        Space
    </div>
    <div id="altgr" class="key">
      AltGr
    </div>
    <div id="super-right" class="key super right">
      &hearts;
    </div>
    <div class="key">
      ???
    </div>
    <div id="ctrl-right" class="key ctrl right">
      Ctrl
    </div>
    </div><!-- end section-a-->

    <div class="section-b">
      <div class="key function small">
        Prnt Scrn
      </div>
      <div class="key function small">
        Scroll Lock
      </div>
      <div class="key function small">
        Pause Break
      </div>

      <dic class="sec-func">
      <div class="key">
        Insert
      </div>
      <div class="key">
        Home
      </div>
      <div class="key dual">
        Page Up
      </div>
      <div class="key">
        Del
      </div>
      <div class="key">
        End
      </div>
        <div class="key dual">
        Page Down
      </div>

        <div class="arrows">
      <div class="key hidden">

      </div>
      <div class="key">
        ^
      </div>
      <div class="key hidden">

      </div>
      <div class="key">
        <
      </div>
      <div class="key">
        v
      </div>
        <div class="key">
        >
      </div>
        </div><!-- end arrows -->
      </div><!-- end sec-func -->


    </div><!-- end section-b-->

  </div>
</div>

              
            
!

CSS

              
                ::selection{background-color:none; color:inherit;}

.flag {
  width: 100px;
  height: 60px;
  background: #c60c30;
}
.flag:before {
  content: "";
  position: absolute;
  width: 10px;
  height: 60px;
  left: 25px;
  background: #fff;
}
.flag:after {
  content: "";
  position: absolute;
  width: 100px;
  height: 10px;
  top: 24px;
  background: #fff;
}

body {
  background-color: #aaa;
}

.keyboard{
  width:800px; height: 320px;
  margin: 0px auto;
  border-radius: 9px;
  padding: 30px;
  color: #eee;
  display: inline-block;
}

.key{
  display:none;
  color: white;
  width: 40px; height:40px;
  display:block;
  background-color:#333;
  text-align: left;
  padding-left: 8px;
  line-height: 29px;
  border-radius:2px;
  float:left; margin-left: 2px;
  margin-bottom:2px;
  cursor: pointer;
  transition: box-shadow 0.7s ease;
}

.section-a{width:650px; height:260px; float:left;}
.section-b{width:150px; height:260px; float:left;}

.function{font-size: 12px; width:30px; height:30px; margin-bottom:15px;}
.small{font-size:10px; line-height:13px; text-align: center; padding:0 5px; padding-top:2px; height:28px !important;}
.space1{margin-right: 43px !important;}
.space2{margin-right: 25px !important;}
.dual {font-size: 14px; line-height: 20px; width:30px; }
.backspace {width:84px; font-size: 12px;}
.tab {width: 50px; line-height: 40px; font-size:13px;}
.letter{width:30px;}
.slash{width:64px;}
.caps{width:70px; font-size:12px; line-height:18px;}
.enter{border-top: 5px solid #333; margin-top: -5px; width:52px; line-height:40px; text-align: center; padding-left:0;}
.shift.left{width: 50px;line-height: 40px; font-size:13px;}
.shift.right{width: 104px;line-height: 40px; font-size:13px;}
.ctrl{width: 50px; line-height: 40px; font-size:13px;}
.space{width:234px; text-align: center;}
.arrows{position:relative; top:42px;}
.sec-func .key{width: 32px; font-size:10px; text-align:left; line-height:40px; float:left;}
.sec-func div.dual{line-height:20px;}
.arrows .key{text-align: center; padding-left: 7px; margin-left:2px;}
.hidden{visibility: hidden;}
.key:hover{box-shadow:0px 0px 10px #14B524; z-index:1000;}

.operator {
  color: black;
  width: 40px; height:40px;
  display: block;
  text-align: center;
  line-height: 40px;
  border-radius:2px;
  float:left; margin-left: 2px;
  margin-bottom:2px;
  font-size: 40px;
}

.result {
  color: black;
  width: 40px; height:40px;
  display: block;
  text-align: center;
  line-height: 35px;
  border-bottom: 4px double black;
  float:left; margin-left: 2px;
  margin-bottom:2px;
  font-size: 35px;
}

.cheatsheet {
  display: inline-block;
}

.guide {
  display: block;
}

.container {
  display: flex;
}

.highlight {
  display: block;
  background-color: red !important;
}
              
            
!

JS

              
                // forked from https://codepen.io/attilahajzer/pen/kydqJ

var keyCodeToId = {
  48: "zero",
  49: "one",
  50: "two",
  51: "three",
  52: "four",
  53: "five",
  54: "six",
  55: "seven",
  56: "eight",
  57: "nine",
  47: "seven",
  219: "tick",
  226: "less",
  18: "altgr",
  16: "shift",
  188: "comma",
  190: "dot",
  189: "dash",
  9: "tab",
  91: "super",
}
  
$(document).keydown(function(event) {
  console.log(event.keyCode)
  $("#" + keyCodeToId[event.keyCode]).addClass("highlight");
});

$(document).keyup(function(event) {
   console.log(event.keyCode)
   $("#" + keyCodeToId[event.keyCode]).removeClass("highlight");
});
              
            
!
999px

Console