<div class="keyboard">
  <button class="keyboard__key keyboard__key--meta" type="button" data-key="cmd">
    <span class="keyboard__key-lines">
      <svg class="keyboard__cmd keyboard__key-line--tr" viewBox="0 0 16 16" width="16px" height="16px" aria-hidden="true">
        <path fill="none" stroke="currentcolor" stroke-width="2" d="M5.7,10.3v2.3c0,1.3-1,2.3-2.3,2.3S1,14,1,12.7s1-2.3,2.3-2.3H5.7z M5.7,10.3h4.7 M5.7,10.3V5.7M10.3,10.3v2.3c0,1.3,1,2.3,2.3,2.3s2.3-1,2.3-2.3s-1-2.3-2.3-2.3H10.3z M10.3,10.3V5.7 M10.3,5.7H5.7 M10.3,5.7V3.3c0-1.3,1-2.3,2.3-2.3S15,2,15,3.3s-1,2.3-2.3,2.3H10.3z M5.7,5.7V3.3C5.7,2,4.6,1,3.3,1S1,2,1,3.3s1,2.3,2.3,2.3H5.7z" />
      </svg>
      <small class="keyboard__key-line keyboard__key-line--small keyboard__key-line--br">command</small>
    </span>
  </button>
  <button class="keyboard__key" type="button" data-key="c">
    <span class="keyboard__key-lines">
      <span class="keyboard__key-line">C</span>
    </span>
  </button>
  <button class="keyboard__key" type="button" data-key="v">
    <span class="keyboard__key-lines">
      <span class="keyboard__key-line">V</span>
    </span>
  </button>
</div>
* {
  border: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --hue: 0;
  --sat: 0%;
  --bg: hsl(var(--hue),var(--sat),90%);
  --fg: hsl(var(--hue),var(--sat),10%);
  --trans-dur: 0.3s;
  font-size: calc(16px + (24 - 16) * (100vw - 320px) / (2560 - 320));
}
body,
button {
  color: var(--fg);
  font: 1em/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
}
body {
  background-color: var(--bg);
  background-image: linear-gradient(-45deg,hsla(var(--hue),var(--sat),0%,0),hsla(var(--hue),var(--sat),0%,0.3));
  display: flex;
  height: 100vh;
  transition:
    background-color var(--trans-dur),
    color var(--trans-dur);
}
.keyboard,
.keyboard:before,
.keyboard:after {
  transition:
    background-color var(--trans-dur),
    box-shadow var(--trans-dur);
}
.keyboard,
.keyboard__key-lines {
  display: flex;
}
.keyboard {
  background-color: hsl(var(--hue),var(--sat),80%);
  background-image: linear-gradient(90deg,hsla(var(--hue),var(--sat),10%,0.4),hsla(var(--hue),var(--sat),10%,0));
  border-radius: 0.75em;
  box-shadow:
    -0.5em -0.5em 0.75em hsla(0,0%,0%,0.6),
    0 0 0 1px hsl(var(--hue),var(--sat),67%) inset;
  align-items: center;
  margin: auto;
  padding: 0.375em;
  position: relative;
  width: 18.5em;
  height: 6.5em;
}
.keyboard:before,
.keyboard:after {
  background-color: hsl(var(--hue),var(--sat),90%);
  content: "";
  display: block;
  position: absolute;
  bottom: 100%;
}
.keyboard:before {
  box-shadow:
    -0.5em -0.5em 0.75em hsla(0,0%,0%,0.6),
    0.25em 0 0.25em hsla(var(--hue),var(--sat),10%,0.2) inset,
    0.25em -1.25em 0.5em hsla(var(--hue),var(--sat),10%,0.5) inset;
  left: calc(50% - 0.5em);
  width: 1em;
  height: 40em;
}
.keyboard:after {
  border-radius: 0.25em 0.25em 0 0;
  box-shadow: 0.375em -0.25em 0.5em hsla(var(--hue),var(--sat),10%,0.5) inset;
  left: calc(50% - 0.75em);
  width: 1.5em;
  height: 1.25em;
}
.keyboard__cmd {
  display: block;
  width: 1em;
  height: 1em;
}
.keyboard__key {
  background-color: hsl(var(--hue),var(--sat),95%);
  border-radius: 0.5em;
  box-shadow:
    -0.4em -0.25em 0.25em hsla(0,0%,0%,0.25),
    0 0 0 0.1em hsla(0,0%,0%,0.3),
    0.04em 0.04em 0.04em hsla(0,0%,0%,0.4) inset,
    -0.1em -0.1em 0.04em hsla(0,0%,100%,0.8) inset;
  color: hsl(var(--hue),var(--sat),50%);
  margin: 0 0.375em;
  outline: transparent;
  padding: 0.75em;
  position: relative;
  width: 5em;
  height: 5em;
  transition:
    background-color var(--trans-dur),
    box-shadow 0.15s,
    color var(--trans-dur);
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.keyboard__key--meta {
  width: 5.5em;
}
.keyboard__key:active,
.keyboard__key.active {
  box-shadow:
    0 0 0.2em hsla(0,0%,0%,0.2),
    0 0 0 0.1em hsla(0,0%,0%,0.4),
    0 -0.05em 0 hsla(0,0%,0%,0.6) inset,
    -0.05em -0.15em 0.05em hsla(0,0%,100%,0.8) inset;
}
.keyboard__key-line {
  font-size: 2em;
  line-height: 1;
}
.keyboard__key-line--small {
  font-size: 0.875em;
}
.keyboard__key-line--tr {
  margin: 0 0 auto auto;
}
.keyboard__key-line--br {
  margin: auto 0 0 auto;
}
.keyboard__key-lines {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  width: 100%;
  height: 100%;
  transition: transform 0.15s;
}
.keyboard__key:active .keyboard__key-lines,
.keyboard__key.active .keyboard__key-lines {
  transform: translateY(-1px);
}
.keyboard__key:before {
  box-shadow: 0 0 0 0.5em hsla(223,90%,50%,0);
  border-radius: 0.5em;
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: box-shadow var(--trans-dur);
}
.keyboard__key:focus-visible:before {
  box-shadow: 0 0 0 0.5em hsla(223,90%,50%,0.5);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: hsl(var(--hue),var(--sat),20%);
    --fg: hsl(var(--hue),var(--sat),90%);
  }
  .keyboard__key {
    background-color: hsl(var(--hue),var(--sat),15%);
    box-shadow:
      -0.4em -0.25em 0.25em hsla(0,0%,0%,0.25),
      0 0 0 0.1em hsla(0,0%,0%,0.3),
      0.04em 0.04em 0.04em hsla(0,0%,0%,0.4) inset,
      -0.1em -0.1em 0.04em hsla(0,0%,100%,0.05) inset;
    color: hsl(var(--hue),var(--sat),90%);
  }
  .keyboard__key:active,
  .keyboard__key.active {
    box-shadow:
      0 0 0.2em hsla(0,0%,0%,0.2),
      0 0 0 0.1em hsla(0,0%,0%,0.4),
      0 -0.05em 0 hsla(0,0%,0%,0.4) inset,
      -0.05em -0.15em 0.05em hsla(0,0%,100%,0.05) inset;
  }
}
window.addEventListener("DOMContentLoaded",() => {
  const c = new CopypasteKeyboard(".keyboard");
});

class CopypasteKeyboard {
  constructor(el) {
    this.el = document.querySelector(el);

    this.init();
  }
  get isMac() {
    return /(Mac|iP[ahno]+[de])/i.test(navigator.userAgent);
  }
  init() {
    window.addEventListener("keydown",this.keyAction.bind(this,true));
    window.addEventListener("keyup",this.keyAction.bind(this,false));
  }
  keyAction(down,e) {
    let { key } = e;
    const isCmd = key === "Meta" && this.isMac;
    const isCtrl = key === "Control" && !this.isMac; // for non-Apple only

    if (isCmd || isCtrl) key = "cmd";

    const keyEl = this.el?.querySelector(`[data-key="${key}"]`);
    const activeClass = "active";

    if (down === true) keyEl?.classList.add(activeClass);
    else keyEl?.classList.remove(activeClass);
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.