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.


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.


  <h2>Using <code>event.getModifierState()</code></h2>

  <p>Use the drop-down to select which modifier key you want to detect. The page will display a  message while the key is pressed. Note that not all keys will display a message on all OS's and some keys (e.g. Alt and Win) will take focus away from the page.</p>

  <select id="modifier">
    <option value="Shift">Shift</option>
    <option value="Control">CTRL</option>
    <option value="CapsLock">Caps Lock</option>
    <option value="NumLock">Num Lock</option>
    <option value="ScrollLock">Scroll Lock</option>
    <option value="Alt">Alt</option>
    <option value="AltGraph">CTRL-ALT</option>
    <option value="Meta">Windows Key (Meta)</option>
    <option value="Fn">Function</option>
    <option value="FnLock">Function Lock</option>
    <option value="Hyper">Hyper</option>
    <option value="Super">Super</option>
    <option value="Symbol">Symbol</option>
    <option value="SymbolLock">Symbol Lock</option>
    <option value="OS">OS Key</option>




                body {
  font-family: Arial, sans-serif;
  font-size: 20px;
  padding: 0 20px;

main {
  text-align: center;
  margin: 0 auto;
  max-width: 800px;

p {
  padding: 0 20px;

code {
  color: firebrick;

output {
  display: block;
  font-weight: bold;
  color: red;
  padding: 20px;

select {
  padding: 5px;
  width: 260px;


                let output = document.querySelector('output'),
    select = document.querySelector('select');

window.addEventListener('keydown', detectModifier);
window.addEventListener('keyup', detectModifier);

function detectModifier (e) {
  let myModifier = select.value;
  if (e.getModifierState(myModifier)) {
    output.innerHTML = `The ${myModifier} Key is Enabled`;
  } else {
    output.innerHTML = '';

/* The code below is for caps lock detection:

window.addEventListener('keydown', detectCapslock);
window.addEventListener('keyup', detectCapslock);

function detectCapslock (e) {
  if (e.getModifierState('CapsLock')) {
    output.innerHTML = 'The CapsLock Key is Enabled';
  } else {
    output.innerHTML = '';