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

              
                <form class="form">
  <input type="text" class="input" value="Нажми на меня" placeholder="Focus this input" />
  <div class="shortcut-helper-menu hidden">
    <h1 class="header">Клавииатурные сокращения</h1>
    <div class="shortcut">
      <div class="label">Воспроизвести/Пауза</div>
      <div class="key-command">
        <span class="key key-16">Шифт</span> + <span class="key key-32">Пробел</span>
      </div>
    </div>
    <div class="shortcut">
      <div class="label">Промотать вперёд</div>
      <div class="key-command">
        <span class="key key-16">Шифт</span> + <span class="key key-39">Стрелка вправо</span>
      </div>
    </div>
    <div class="shortcut">
      <div class="label">Промотать назад</div>
      <div class="key-command">
        <span class="key key-16">Шифт</span> + <span class="key key-37">Стрелка влево</span>
      </div>
    </div>
  </div>
</form>
              
            
!

CSS

              
                body {
  font: 16px/1.4 'Proxima Nova', sans-serif;
  letter-spacing: .05em;
  background: #1f242a;
  color: #1f242a;
}

.form {
  width: 200px;
  margin: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.form .input {
  display: block;
  line-height: 2rem;
  text-align: center;
  width: 100%;
}

.shortcut-helper-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  padding: 1rem;
  background: #eee;
  opacity: .9;
  margin-bottom: 1rem;
  border-radius: 4px;
  width: 500px;
}
.shortcut-helper-menu:after {
  content: '';
  display: block;
  width: 0;
  border-style: solid;
  border-width: 10px 10px 0;
  border-color: #eee transparent transparent;
  position: absolute;
  top: 100%;
  left: 10px;
}
.shortcut-helper-menu.hidden {
  display: none;
}
.shortcut-helper-menu.shown {
  display: block;
}

.header {
  font-weight: 600;
  margin-bottom: 1rem;
}

.shortcut {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  white-space: nowrap;
}

.label {
  margin-right: 1rem;
  width: 200px;
}

.key {
  display: inline-block;
  background: #ddd;
  line-height: 1.6rem;
  padding: 0 .5rem;
  border-radius: 4px;
}
.key.pressed {
  background: #00c7b2;
}

              
            
!

JS

              
                var input = document.querySelector('.input');
var helperMenu = document.querySelector('.shortcut-helper-menu');

function addHighlight(keyCode) {
  $('.key-' + keyCode).addClass('pressed');
}

function removeHighlight(keyCode) {
  $('.key-' + keyCode).removeClass('pressed');
}

window.addEventListener('keydown', function(event) {
  if (event.shiftKey) {
    event.preventDefault();
  }
  console.log(event.keyCode);
  addHighlight(event.keyCode);
});

window.addEventListener('keyup', function(event) {
  removeHighlight(event.keyCode);
});

input.addEventListener('focus', function() {
  $(helperMenu).toggleClass('hidden', 'shown');
})

input.addEventListener('blur', function() {
  $(helperMenu).toggleClass('hidden', 'shown');
})
              
            
!
999px

Console