Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


                <div id='mac'>
  <div id='no-focus'>
    Click to Wake
<div id='kb'>
  <div class='kb-row'>
    <div class='k k-tld' id='kc-192' pre='~' suf=''></div>
    <div class='k k-1' id='kc-49' pre='!' suf='1'></div>
    <div class='k k-2' id='kc-50' pre='@' suf='2'></div>
    <div class='k k-3' id='kc-51' pre='#' suf='3'></div>
    <div class='k k-4' id='kc-52' pre='$' suf='4'></div>
    <div class='k k-5' id='kc-53' pre='%' suf='5'></div>
    <div class='k k-6' id='kc-54' pre='^' suf='6'></div>
    <div class='k k-7' id='kc-55' pre='&amp;' suf='7'></div>
    <div class='k k-8' id='kc-56' pre='*' suf='8'></div>
    <div class='k k-9' id='kc-57' pre=')' suf='9'></div>
    <div class='k k-0' id='kc-48' pre='(' suf='0'></div>
    <div class='k k-min' id='kc-189' pre='_' suf='-'></div>
    <div class='k k-eq' id='kc-187' pre='+' suf='='></div>
    <div class='k k-del k-txt' id='kc-8' suf='delete'></div>
  <div class='kb-row'>
    <div class='k k-tab k-txt' id='kc-9' suf='tab'></div>
    <div class='k k-q' id='kc-81' pre='q'></div>
    <div class='k k-w' id='kc-87' pre='w'></div>
    <div class='k k-e' id='kc-69' pre='e'></div>
    <div class='k k-r' id='kc-82' pre='r'></div>
    <div class='k k-t' id='kc-84' pre='t'></div>
    <div class='k k-y' id='kc-89' pre='y'></div>
    <div class='k k-u' id='kc-85' pre='u'></div>
    <div class='k k-i' id='kc-73' pre='i'></div>
    <div class='k k-o' id='kc-79' pre='o'></div>
    <div class='k k-p' id='kc-80' pre='p'></div>
    <div class='k k-obrace' id='kc-219'></div>
    <div class='k k-cbrace' id='kc-221'></div>
    <div class='k k-bslash' id='kc-220' pre='|' suf='\ '></div>
  <div class='kb-row'>
    <div class='k k-caps k-txt' id='kc-20' pre='•' suf='caps lock'></div>
    <div class='k k-a' id='kc-65' pre='a'></div>
    <div class='k k-s' id='kc-83' pre='s'></div>
    <div class='k k-d' id='kc-68' pre='d'></div>
    <div class='k k-f' id='kc-70' pre='f'></div>
    <div class='k k-g' id='kc-71' pre='g'></div>
    <div class='k k-h' id='kc-72' pre='h'></div>
    <div class='k k-j' id='kc-74' pre='j'></div>
    <div class='k k-k' id='kc-75' pre='k'></div>
    <div class='k k-l' id='kc-76' pre='l'></div>
    <div class='k k-semi' id='kc-186' pre=':' suf=';'></div>
    <div class='k k-quot' id='kc-222' pre='"' suf="'"></div>
    <div class='k k-return k-txt' id='kc-13' pre='enter' suf='return'></div>
  <div class='kb-row'>
    <div class='k k-lshift k-txt' id='kc-16L' suf='shift'></div>
    <div class='k k-z' id='kc-90' pre='z'></div>
    <div class='k k-x' id='kc-88' pre='x'></div>
    <div class='k k-c' id='kc-67' pre='c'></div>
    <div class='k k-v' id='kc-86' pre='v'></div>
    <div class='k k-b' id='kc-66' pre='b'></div>
    <div class='k k-n' id='kc-78' pre='n'></div>
    <div class='k k-m' id='kc-77' pre='m'></div>
    <div class='k k-comma' id='kc-188' pre='&lt;' suf=','></div>
    <div class='k k-period' id='kc-190' pre='&gt;' suf='.'></div>
    <div class='k k-fslash' id='kc-191' pre='?' suf='/'></div>
    <div class='k k-rshift k-txt' id='kc-16R' suf='shift'></div>
  <div class='kb-row'>
    <div class='k k-func k-txt' suf='fn'></div>
    <div class='k k-ctrl k-txt' id='kc-17' suf='control'></div>
    <div class='k k-lopt k-txt' id='kc-18L' pre='alt' suf='option'></div>
    <div class='k k-lcmnd k-txt' id='kc-91' pre='⌘' suf='command'></div>
    <div class='k k-space' id='kc-32'></div>
    <div class='k k-rcmnd k-txt' id='kc-93' pre='⌘' suf='command'></div>
    <div class='k k-ropt k-txt' id='kc-18R' pre='alt' suf='option'></div>
    <div class='k k-larr' id='kc-37' pre='▸'></div>
    <div class='k k-arr-udarr'>
      <div class='k k-uarr' id='kc-38' pre='▾'></div>
      <div class='k k-darr' id='kc-40' pre='▾'></div>
    <div class='k k-rarr' id='kc-39' pre='▸'></div>


                @import url(,400|Inconsolata)
// millimeter
$mil: 24px

// keyboard vars
$k-br: $mil * 0.15 // border radius
$kb-inset: $mil * 0.4 // keyboard inset
$k-h: $mil * 1.5 // key height
$a-h: $k-h / 2 // arrow height
$k-w: $mil * 1.5 // standard
$k-w-2: $mil * 2 // cmnds
$k-w-25: $mil * 2.5 // del and tab
$k-w-3: $mil * 3 // caps and return
$k-w-39: $mil * 3.9 // shifts
$k-w-91: $mil * 9.1 // spacebar
$kb-sp: $mil * 0.35 // spacing
$kb-r-w: ($k-w-2 * 2) + ($k-w * 7) + $k-w-91 + ($kb-sp * 9) // row width

$c-kb-bg: #f0f0f0 // keyboard background
$c-k-bg: #fff // key background
$c-k-c: #444 // key color
$c-b-bg: #7F8C8D // body bg

$c-mac: #222 // 
$c-mac-screen: #444 // screen color

// mac vars
$m-h-s: $mil * 12
$m-w-s: $kb-r-w

  margin: 0
  background-color: $c-b-bg
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, sans-serif

// mac style
  overflow-y: hidden
  animation: mac-intro 200ms forwards 1.5s
  max-height: 0
  padding: 0
  margin: 0 auto
  box-shadow: 0px 0px 0px 0px darken($c-b-bg, 30%)
  width: $m-w-s + ($kb-inset * 2)
  box-sizing: border-box
  background-color: $c-mac
  border-radius: 16px
  position: relative
    border: none
    outline: none
    box-sizing: border-box
    resize: none
    font-family: Inconsolata, monospace
    padding: 24px
    font-size: $mil / 2
    line-height: 1.4
    background-color: $c-mac-screen
    color: $c-k-bg
    height: $m-h-s
    width: 100%
    position: relative
    opacity: 0.4
    transition: opacity 200ms
      opacity: 1
      & ~ #no-focus
        opacity: 0
        animation: none
    position: absolute
    animation: glow 1s infinite
    transition: opacity 200ms
    color: white
    text-transform: uppercase
    display: block
    top: 50%
    left: 50%
    transform: translate(-50%,-50%)
    cursor: pointer
    pointer-events: none
// keyboard style  
  padding: $kb-inset
  box-sizing: border-box
  background-color: $c-kb-bg
  width: $kb-r-w + ($kb-inset * 2)
  border-radius: $k-br * 2
  margin: 24px auto
  box-shadow: 0px 4px 0px 2px darken($c-kb-bg, 20%)
  margin-bottom: $kb-sp
  font-size: 0
  width: $kb-r-w
    margin-bottom: 0
  display: inline-block
  position: relative
  width: $k-w
  height: $k-h
  margin-right: $kb-sp
  border-radius: $k-br
  background-color: $c-k-bg
  color: $c-k-c
  box-shadow: 0px 2px 0px 1px darken($c-kb-bg, 10%)
  // active style
    box-shadow: 0px -1px 0px 1px darken($c-kb-bg, 10%)
  // far right child
    margin-right: 0
    float: right
  // labels
    content: attr(pre) '\a' attr(suf)
    white-space: pre
    text-align: center
    position: absolute
    font-size: $mil / 2
    text-transform: uppercase
    top: 50%
    left: 50%
    transform: translate(-50%,-50%)
  // text content
      font-size: $mil / 3
      text-transform: none
  // caps lock
      content: attr(pre) '\a'
      top: $kb-sp / 2
      font-size: $mil / 2 !important
        color: #2ecc71
        text-shadow: 0px 0px 4px lighten(#2ecc71, 20%)
      content: '\a' attr(suf)
      bottom: $kb-sp / 2
      white-space: pre
      position: absolute
      font-size: $mil / 3
      text-align: left
      width: 80%
      left: $kb-sp / 2
      top: auto
      transform: translate(0, 0)
  // arrows
  &.k-larr, &.k-rarr, &.k-uarr, &.k-darr
    height: $a-h
    line-height: $a-h
  // up and down arrow
    display: inline-block
    width: $k-w
    height: $k-h
    margin-right: $kb-sp
    background-color: transparent
    &, &.active
      box-shadow: none
      display: block
      margin: 0 0 1px
        border-radius: $k-br $k-br 0 0
        marigin-bottom: 0
        border-radius: 0 0 $k-br $k-br 
  // right arrow
    margin-top: $a-h
  // cmnds
  &.k-lcmnd, &.k-rcmnd
    width: $k-w-2
  // tab and delete
  &.k-tab, &.k-del
    width: $k-w-25
  // caps and return
  &.k-caps, &.k-return
    width: $k-w-3
  // shifts
  &.k-lshift, &.k-rshift
    width: $k-w-39
  // space
    width: $k-w-91
  // :before overrides
    text-align: left
    width: 80%
    left: $kb-sp / 2
    top: auto
    bottom: $kb-sp / 2
    transform: translate(0, 0)

    text-align: right
    left: auto
    right: $kb-sp / 2
    top: auto
    bottom: $kb-sp / 2
    transform: translate(0, 0)

  // right aligns
  &.k-del, &.k-return, &.k-rshift, &.k-ropt, &.k-lcmnd
  // left aligns
  &.k-rcmnd, &.k-lopt, &.k-ctrl, &.k-fn, &.k-lshift, &.k-caps, &.k-tab, &.k-func
  // `
      content: attr(pre) '\a `'
      content: '{\a['
      content: '}\a]'
  &.k-uarr, &.k-larr
      transform: translate(-50%, -50%) rotate(180deg)  
@keyframes mac-intro
    max-height: 0
    padding: 0
    margin: 0 auto
    box-shadow: 0px 0px 0px 0px darken($c-b-bg, 30%)
    max-height: $m-h-s + ($kb-inset * 8)
    margin: 24px auto 0
    padding: $kb-inset * 4
    box-shadow: 0px 2px 0px 1px darken($c-b-bg, 30%)
@keyframes glow
    opacity: 1
    opacity: 0.2
    opacity: 1


                $('#mac textarea').keydown (e) ->
  code = e.keyCode || e.which
  #console.log code
  if code == 18 || code == 16

  # spaces on tab
  if code == 9
    start = @selectionStart
    end = @selectionEnd
    $this = $(this)
    value = $this.val()
    $this.val value.substring(0, start) + "  " + value.substring(end)
    @selectionStart = @selectionEnd = start + 2

$('#mac').keyup (e) ->
  code = e.keyCode || e.which
  if code == 18 || code == 16