Pen Settings

HTML

CSS

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

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

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.

HTML

              
                body
  main
    .input(data-text='Try me!')
    .keyboard
      .key.l.label.lt
        span esc
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M11.8,10c0,1-0.8,1.8-1.8,1.8S8.2,11,8.2,10S9,8.2,10,8.2S11.8,9,11.8,10z M10,13.8v0.7 M10,5.5v0.7 M13.8,10 h0.7 M5.5,10h0.7 M12.7,12.7l0.5,0.5 M6.8,6.8l0.5,0.5 M13.2,6.8l-0.5,0.5 M6.8,13.2l0.5-0.5')
        span f1
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M12.4,10c0,1.3-1.1,2.4-2.4,2.4S7.6,11.3,7.6,10S8.7,7.6,10,7.6S12.4,8.7,12.4,10z M10,14.4V16 M10,4v1.6 M14.4,10H16 M4,10h1.6 M13.1,13.1l1.1,1.1 M5.7,5.7l1.1,1.1 M13.1,6.9l1.1-1.1 M5.7,14.3l1.1-1.1')
        span f2
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M8.5,8.8H2c-0.3,0-0.5-0.2-0.5-0.5v-3c0-0.3,0.2-0.5,0.5-0.5h6.5C8.7,4.8,9,5.1,9,5.3v3C9,8.6,8.7,8.8,8.5,8.8 z M11.4,14.7v-3c0-0.3-0.2-0.5-0.5-0.5H5.4c-0.3,0-0.5,0.2-0.5,0.5v3c0,0.3,0.2,0.5,0.5,0.5h5.4C11.1,15.2,11.4,14.9,11.4,14.7z M18.5,12.4V6.4c0-0.3-0.2-0.5-0.5-0.5h-3.5c-0.3,0-0.5,0.2-0.5,0.5v5.9c0,0.3,0.2,0.5,0.5,0.5H18C18.3,12.9,18.5,12.6,18.5,12.4z')
        span f3
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M5,15.1H2c-0.3,0-0.5-0.2-0.5-0.5v-3c0-0.3,0.2-0.5,0.5-0.5h3c0.3,0,0.5,0.2,0.5,0.5v3 		C5.5,14.9,5.3,15.1,5,15.1z M12,14.6v-3c0-0.3-0.2-0.5-0.5-0.5h-3c-0.3,0-0.5,0.2-0.5,0.5v3c0,0.3,0.2,0.5,0.5,0.5h3 C11.8,15.1,12,14.9,12,14.6z M18.5,14.6v-3c0-0.3-0.2-0.5-0.5-0.5h-3c-0.3,0-0.5,0.2-0.5,0.5v3c0,0.3,0.2,0.5,0.5,0.5h3 C18.3,15.1,18.5,14.9,18.5,14.6z M5.5,8.4v-3c0-0.3-0.2-0.5-0.5-0.5H2c-0.3,0-0.5,0.2-0.5,0.5v3c0,0.3,0.2,0.5,0.5,0.5h3 C5.3,8.9,5.5,8.7,5.5,8.4z M12,8.4v-3c0-0.3-0.2-0.5-0.5-0.5h-3C8.2,4.9,8,5.1,8,5.4v3c0,0.3,0.2,0.5,0.5,0.5h3 C11.8,8.9,12,8.7,12,8.4z M18.5,8.4v-3c0-0.3-0.2-0.5-0.5-0.5h-3c-0.3,0-0.5,0.2-0.5,0.5v3c0,0.3,0.2,0.5,0.5,0.5h3 C18.3,8.9,18.5,8.7,18.5,8.4z')
        span f4
      .key.func
        span f5
      .key.func
        span f6
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M9.7,6.5v6.9l-6-3.5L9.7,6.5z M9.7,10l6,3.5V6.5L9.7,10z')
        span f7
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M10.4,10l-6,3.5V6.5L10.4,10z M12.6,6.5v6.9 M15.6,6.5v6.9')
        span f8
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M16.3,10l-6,3.5V6.5L16.3,10z M4.3,6.5v6.9l6-3.5L4.3,6.5z')
        span f9
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M13,14.2l-3.3-2.5H7.5c-0.3,0-0.5-0.2-0.5-0.5V8.9c0-0.3,0.2-0.5,0.5-0.5h2.2L13,5.8V14.2z')
        span f10
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M11.5,14.2l-3.3-2.5H6.1c-0.3,0-0.5-0.2-0.5-0.5V8.9c0-0.3,0.2-0.5,0.5-0.5h2.2l3.3-2.5V14.2z M13.6,13 c0.5-0.9,0.8-1.9,0.8-3c0-1.1-0.3-2.1-0.8-3')
        span f11
      .key.func
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M9,14.2l-3.3-2.5H3.6c-0.3,0-0.5-0.2-0.5-0.5V8.9c0-0.3,0.2-0.5,0.5-0.5h2.2L9,5.8V14.2z M11.1,13 c0.5-0.9,0.8-1.9,0.8-3c0-1.1-0.3-2.1-0.8-3 M13.2,14.5c0.8-1.3,1.3-2.8,1.3-4.5c0-1.7-0.5-3.2-1.3-4.5 M15.1,16 c1.1-1.7,1.8-3.8,1.8-6c0-2.2-0.7-4.3-1.8-6')
        span f12
      .key.icon
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M14.6,9.9H5.4L10,5.8L14.6,9.9z M14.6,14v-1.7c0-0.1-0.1-0.3-0.3-0.3H5.6c-0.1,0-0.3,0.1-0.3,0.3V14 c0,0.1,0.1,0.3,0.3,0.3h8.7C14.5,14.2,14.6,14.1,14.6,14z')

      .key.double
        span.up ~
        span.dw `
      .key.double
        span.up !
        span.dw 1
      .key.double
        span.up @
        span.dw 2
      .key.double
        span.up #
        span.dw 3
      .key.double
        span.up $
        span.dw 4
      .key.double
        span.up %
        span.dw 5
      .key.double
        span.up ^
        span.dw 6
      .key.double
        span.up &
        span.dw 7
      .key.double
        span.up *
        span.dw 8
      .key.double
        span.up (
        span.dw 9
      .key.double
        span.up )
        span.dw 0
      .key.double
        span.up —
        span.dw -
      .key.double
        span.up +
        span.dw =
      .key.l.label.rt.del
        span delete

      .key.l.label.lt
        span tab
      .key.lttr
        span q
      .key.lttr
        span w
      .key.lttr
        span e
      .key.lttr
        span r
      .key.lttr
        span t
      .key.lttr
        span y
      .key.lttr
        span u
      .key.lttr
        span i
      .key.lttr
        span o
      .key.lttr
        span p
      .key.double
        span.up {
        span.dw [
      .key.double
        span.up }
        span.dw ]
      .key.double
        span.up |
        span.dw \

      .key.xl.label.lt.lock
        span caps lock
      .key.lttr
        span a
      .key.lttr
        span s
      .key.lttr
        span d
      .key.lttr.tch
        span f
      .key.lttr
        span g
      .key.lttr
        span h
      .key.lttr.tch
        span j
      .key.lttr
        span k
      .key.lttr
        span l
      .key.double
        span.up :
        span.dw ;
      .key.double
        span.up "
        span.dw '
      .key.xl.label.rt
        span return

      .key.xxl.label.lt
        span shift
      .key.lttr
        span z
      .key.lttr
        span x
      .key.lttr
        span c
      .key.lttr
        span v
      .key.lttr
        span b
      .key.lttr
        span n
      .key.lttr
        span m
      .key.double
        span.up <
        span.dw ,
      .key.double
        span.up >
        span.dw .
      .key.double
        span.up ?
        span.dw /
      .key.xxl.label.rt
        span shift

      .key.label.lt
        span fn
      .key.label.rt
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          polyline(points='14.6,9.7 10,4.6 5.4,9.7')
        span control
      .key.label.rt
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M17,9.7H9.7L6.9,4.5H3 M10.6,4.5H17')
        span option
      .key.m.label.rt
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M8,8H6.2c-1,0-1.8-0.8-1.8-1.8v0c0-1,0.8-1.8,1.8-1.8h0c1,0,1.8,0.8,1.8,1.8V8z M12,8H8v4h4V8z M6.2,12 c-1,0-1.8,0.8-1.8,1.8v0c0,1,0.8,1.8,1.8,1.8h0c1,0,1.8-0.8,1.8-1.8V12H6.2z M12,13.8c0,1,0.8,1.8,1.8,1.8h0c1,0,1.8-0.8,1.8-1.8v0 c0-1-0.8-1.8-1.8-1.8H12V13.8z M13.8,8c1,0,1.8-0.8,1.8-1.8v0c0-1-0.8-1.8-1.8-1.8h0c-1,0-1.8,0.8-1.8,1.8V8H13.8z')
        span command
      .key.space &nbsp;
      .key.m.label.lt
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M8,8H6.2c-1,0-1.8-0.8-1.8-1.8v0c0-1,0.8-1.8,1.8-1.8h0c1,0,1.8,0.8,1.8,1.8V8z M12,8H8v4h4V8z M6.2,12 c-1,0-1.8,0.8-1.8,1.8v0c0,1,0.8,1.8,1.8,1.8h0c1,0,1.8-0.8,1.8-1.8V12H6.2z M12,13.8c0,1,0.8,1.8,1.8,1.8h0c1,0,1.8-0.8,1.8-1.8v0 c0-1-0.8-1.8-1.8-1.8H12V13.8z M13.8,8c1,0,1.8-0.8,1.8-1.8v0c0-1-0.8-1.8-1.8-1.8h0c-1,0-1.8,0.8-1.8,1.8V8H13.8z')
        span command
      .key.label.lt
        svg(width='20px' height='20px' viewBox='0 0 20 20')
          path(d='M17,9.7H9.7L6.9,4.5H3 M10.6,4.5H17')
        span option
      .key.arrow.icon.left
          svg(width='20px' height='20px' viewBox='0 0 20 20')
            path(d='M6.8,10.2l6.2,2.9c0.1,0.1,0.3,0,0.3-0.2V7.1c0-0.1-0.2-0.2-0.3-0.2L6.8,9.8C6.7,9.9,6.7,10.1,6.8,10.2z')
      .key.arrow.split
        .btn.top
          svg(width='20px' height='20px' viewBox='0 0 20 20')
            path(d='M9.8,6.9l-2.9,6.2c-0.1,0.1,0,0.3,0.2,0.3h5.8c0.1,0,0.2-0.2,0.2-0.3l-2.9-6.2C10.1,6.8,9.9,6.8,9.8,6.9z')
        .btn.bottom
          svg(width='20px' height='20px' viewBox='0 0 20 20')
            path(d='M10.2,13.2L13.1,7c0.1-0.1,0-0.3-0.2-0.3H7.1C7,6.7,6.9,6.8,6.9,7l2.9,6.2C9.9,13.3,10.1,13.3,10.2,13.2z')
      .key.arrow.icon.right
          svg(width='20px' height='20px' viewBox='0 0 20 20')
            path(d='M13.2,9.8L7,6.9C6.8,6.9,6.7,7,6.7,7.1v5.8c0,0.1,0.2,0.2,0.3,0.2l6.2-2.9C13.3,10.1,13.3,9.9,13.2,9.8z')
              
            
!

CSS

              
                $main: linear-gradient(135deg, rgba(205,207,214,1) 0%,rgba(190,192,196,1) 100%);

$keyBkg: #f5f5f5;
$keyBkgHover: #e5e3e4;
$keyBkgActive: #c5c3c4;
$keycolor: #757374;
$light: #7d7b7c;
$green: #74f583;
$black: #000;
$white: #fff;

*{box-sizing: border-box; outline: 0px;}
::-moz-selection {background: transparent;}
::selection {background: transparent;}

body{font-family: "Work Sans"; margin: 0px;}
  


main{
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  .input{
    display: block;
    position: relative;
    width: 90%;
    height: auto;
    padding: 18px;
    margin: 0px auto 40px auto;
    text-align: center;
    font-family: "Anonymous Pro";
    font-size: 30px;
    line-height: 40px;
    color: $keycolor;
    border: 0px;
    border-bottom: 2px solid #ddd;
    background: transparent;

    &:empty:not(:focus):before{
      content:attr(data-text);
      opacity: .5;
    }
    &:empty:not(:focus):after{
      content:"";
      opacity: 0;
    }
     &:after{
      content:"|";
      opacity: 0;
    }
  }
}


.keyboard{
  display: grid;
  grid-template-columns: repeat(58, 8px);
  grid-template-rows: repeat(6, 56px);
  position:relative;
  width: auto;
  height: auto;
  padding: 10px;
  grid-gap: 8px;
  border-radius: 14px;
  background: $main;
  .key{
    display:block;
    position: relative;
    grid-column: span 4;
    color: $keycolor;
    border-radius: 6px;
    background: $keyBkg;
    border: 1px solid rgba($black,.4);
    box-shadow: 1px 1px 0px 0px rgba($white,.2);
    cursor: pointer;
    &:hover{
      background: $keyBkgHover;
    }
    &:active{
      background: $keyBkgActive;
    }
    &.m{grid-column: span 5;}
    &.l{grid-column: span 6;}
    &.xl{grid-column: span 7;}
    &.xxl{grid-column: span 9;}
    &.space{grid-column: span 20;}
    &.tch:after{
      content:"";
      display: block;
      position: absolute;
      bottom: 10px;
      left: calc(50% - 7px);
      width: 14px;
      height: 3px;
      border-radius: 3px;
      background: transparent;
      box-shadow: 0px 1px 2px rgba($black,.3);
    }
    polyline, path, line{
      fill:none;
      stroke: $light;
      stroke-linecap:round;
      stroke-linejoin:round;
      stroke-miterlimit: 10;
    }
    span{
      display: block;
      position: absolute;
      text-transform: uppercase;
    }
    svg{
      display: block;
      position: absolute;
    }
    &.lttr span{
      width: 100%;
      height: 100%;
      text-align: center;
      font-size: 19px;
      line-height: 54px;
    }
    &.double span{
      width: 100%;
      text-align: center;
      &.up{
        top: 8px;
        font-size: 14px;
        line-height: 12px;
      }
      &.dw{
        bottom: 10px;
        font-size: 19px;
        line-height: 16px;
      }
    }
    &.func span{
      width: 100%;
      bottom: 8px;
      text-align: center;
      font-size: 8px;
      line-height: 8px;
    }
    &.func svg{
      width: 100%;
      top: 8px;
    }
    &.icon svg{
      width: 100%;
      top: 18px;
    }
    &.label{
      color: $light;
      &.lt span{left: 8px;}
      &.rt span{right: 8px;}
      &.lt svg{left: 4px;}
      &.rt svg{right: 4px;}
      span{
        bottom: 8px;
        font-size: 11px;
        font-weight: 400;
        text-transform: none;
      }
      svg{
        top: 4px;
      }
    }
    &.arrow{
      path{
        fill: $light;
        stroke: none;
      }
    }
    &.split{
      .btn{
        display: block;
        position: absolute;
        width: 100%;
        height: 50%;
        svg{
          top: 3px;
          width: 100%;
          path{
            fill: $light;
            stroke: none;
          }
        }
        &.top{
          top: 0px;
          border-bottom:  1px solid rgba($black,.3);
          background: linear-gradient(to bottom, rgba($black,0) 60%,rgba($black,.15) 100%);
        }
        &.bottom{
          bottom: 0px;
          border-top:  1px solid rgba($black,.3);
          background: linear-gradient(to bottom, rgba($black,.15) 0%,rgba($black,0) 40%);
        }
      }
    }
    &.lock:after{
      content:"";
      display: block;
      position: absolute;
      top: 8px;
      left: 8px;
      z-index: 10;
      width: 5px;
      height: 5px;
      border: 1px solid rgba($black,.2);
      border-radius: 16px;
      background: $light;
      opacity: 0.6;
    }
    &.lock.on:after{
      background: $green;
      box-shadow: 0px 0px 4px $green;
    }
  }
}

.key{
  transition: .2s ease-out all; 
  -moz-transition: .2s ease-out all; 
  -webkit-transition: .2s ease-out all;
}

.input:after {
  animation-name: cursor;
  animation-duration: 450ms;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-direction: alternate;
  animation-delay: 2s;
}

@keyframes cursor {
  0%   {opacity: 0}
  100% {opacity: .5}
}
              
            
!

JS

              
                $(".lock").click(function(){
  $(this).toggleClass("on");
});

$(".key").click(function(){
  var $text = $(".input").text();


  
  
  if ($(this).hasClass("lttr") || $(this).hasClass("space")) {
   
    if (!$(".lock").hasClass("on")) {
      $(".input").text($text+$(this).text()); 
    } else {
      $(".input").text($text+$(this).text().toUpperCase()); 
    }
    
  } else if ($(this).hasClass("double")) {
    
    $(".input").text($text+$(this).find(".dw").text()); 
    
  } else if ($(this).hasClass("del")) {
    $(".input").text($text.substr(0, $text.length-1));
  }
  
  if ($text.length > 0) {
    $(".input").addClass("fill");
    console.log($text.length);

  } else {
    $(".input").removeClass("fill");
    console.log($text.length +"ded");
  } 
});
              
            
!
999px

Console