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

              
                <div class="col-sm-12"><div class="row">click in here and start typing
	<input>
	</div></div>
<div class="keyboard">
		<div data-key="192" class="tilde key keys" data-key="192"><span>~<br>`</span></div>
 		<div data-key="49" class="one key keys" data-key="49"><span>1</span></div>
		<div data-key="50" class="two key keys" data-key="50"><span>2</span></div>
		<div data-key="51" class="three key keys" data-key="51"><span>3</span></div>
		<div data-key="52" class="four key keys" data-key="52"><span>4</span></div>
		<div data-key="53" class="five key keys" data-key="53"><span>5</span></div>
		<div data-key="54" class="six key keys" data-key="54"><span>6</span></div>
		<div data-key="55" class="seven key keys" data-key="55"><span>7</span></div>
		<div data-key="56" class="eight key keys" data-key="56"><span>8</span></div>
		<div data-key="57" class="nine key keys" data-key="57"><span>9</span></div>
		<div data-key="48" class="zero key keys" data-key="48"><span>0</span></div>
		<div data-key="189" class="dash key keys" data-key="189"><span>_<br>-</span></div>
		<div data-key="187" class="equal key keys" data-key="187"><span>+<br>=</span></div>
		<div data-key="8" class="backspace key-two keys" data-key="8"><span>backspace</span></div>
	
		<div class="tab key-n-half keys" data-key="9"><span>tab</span></div>
		<div class="Q key keys" data-key="81"><span>Q</span></div>
		<div class="W key keys" data-key="87"><span>W</span></div>
		<div class="E key keys" data-key="69"><span>E</span></div>
		<div class="R key keys" data-key="82"><span>R</span></div>
		<div class="T key keys" data-key="84"><span>T</span></div>
		<div class="Y key keys" data-key="89"><span>Y</span></div>
		<div class="U key keys" data-key="85"><span>U</span></div>
		<div class="I key keys" data-key="73"><span>I</span></div>
		<div class="O key keys" data-key="79"><span>O</span></div>
		<div class="P key keys" data-key="80"><span>P</span></div>
		<div class="open-brace key keys" data-key="219"><span>{&nbsp;&nbsp;[</span></div>
		<div class="close-brace key keys" data-key="221"><span>}&nbsp;&nbsp;]</span></div>
		<div class="back-slash key-n-half keys" data-key="220"><span>\&nbsp;&nbsp;|</span></div>
	
		<div class="caps key-n-half-half keys" data-key="20"><span>caps lock</span><div class="capspan"></div></div>
		<div class="A key keys" data-key="65"><span>A</span></div>
		<div class="S key keys" data-key="83"><span>S</span></div>
		<div class="D key keys" data-key="68"><span>D</span></div>
		<div class="F key keys" data-key="70"><span class="f-span">F</span></div>
		<div class="G key keys" data-key="71"><span>G</span></div>
		<div class="H key keys" data-key="72"><span>H</span></div>
		<div class="J key keys" data-key="74"><span class="j-span">J</span></div>
		<div class="K key keys" data-key="75"><span>K</span></div>
		<div class="L key keys" data-key="76"><span>L</span></div>
		<div class="colon key keys" data-key="186"><span>:&nbsp;&nbsp;;</span></div>
		<div class="quote key keys" data-key="222"><span>"&nbsp;&nbsp;'</span></div>
		<div class="enter key-two-n-half-half keys" data-key="13"><span>enter</span></div>
	
		<div class="shift key-two-n-half-half keys" data-key="16"><span>shift</span></div>
		<div class="Z key keys" data-key="90"><span>Z</span></div>
		<div class="X key keys" data-key="88"><span>X</span></div>
		<div class="C key keys" data-key="67"><span>C</span></div>
		<div class="V key keys" data-key="86"><span>V</span></div>
		<div class="B key keys" data-key="66"><span>B</span></div>
		<div class="N key keys" data-key="78"><span>N</span></div>
		<div class="M key keys" data-key="77"><span>M</span></div>
		<div class="comma key keys" data-key="188"><span>,</span></div>
		<div class="period key keys" data-key="190"><span>.</span></div>
		<div class="for-slash key keys" data-key="191"><span>/</span></div>
		<div class="shift key-three keys" data-key="16"><span>shift</span></div>
	
		<div class="ctrl key-third keys" data-key="17"><span>ctrl</span></div>
		<div class="fn-l key keys"><span>fn</span></div>
		<div class="window key keys"><span><i class="fab fa-windows"></i></span></div>
		<div class="alt key keys" data-key="18"><span>alt</span></div>
		<div class="space-bar space keys" data-key="32"></div>
		<div class="alt key keys" data-key="18"><span>alt</span></div>
		<div class="fn-r key keys"><span>fn</span></div>
		<div class="page key keys"><span><i class="far fa-file-alt"></i></span></div>
		<div class="ctrl key-n-half-half keys" data-key="17"><span>ctrl</span></div>
	
</div>

              
            
!

CSS

              
                body {
	background: #ccc;
}
.keyboard {
	width: 700px;
	height: 250px;
	background: #222222;
	padding: 1%;
	border-radius: 5px;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%,-50%);
}
.keys {
	float: left;
	position: relative;
	height: 20%;
	cursor: pointer;
}
.keys span {
	position: absolute;
	z-index: 5;
	color: #555;
	top: 50%;
	left: 50%;
	transform: translate(-50%,-50%);
	font-weight: bold;
	font-size: 12px;
	white-space: nowrap;
	pointer-events: none;
}
.caps .capspan {
	content: '';
	width: 5px; 
	height: 5px;
	background: black;
	position: absolute;
	top: 7px;
	right: 7px;
	z-index: 2;
	border-radius: 50%;
}
.caps-on .capspan {
	background: #c4daff;
	box-shadow: -2px -2px 7px #87b3ff, 1px 1px 7px #87b3ff;
}

.key {
/* 	width: 6.67%; */
	width: calc(100% / 15);
}
.key-third {
	width: calc(100% / 15 + 1.7%);
}
.key-two {
/* 	width: 13.33%; */
	width: calc(100% / 15 * 2);
}
.key-n-half {
	width: calc(100% / 15 * 1.5);
}
.key-n-half-half {
	--keyboard-width: 100%;
	--width-n-half: calc(var(--keyboard-width) / 15 * 1.5);
	--width-n-half-half: calc(var(--width-n-half) + 1.6%);
	width: var(--width-n-half-half);
/* 	width: var(--width-n-half); */
}
.key-two-n-half-half {
	--keyboard-width: 100%;
	--width-n-half: calc(var(--keyboard-width) / 15 * 1.5);
	--width-n-half-half: calc(var(--width-n-half) + 5%);
	width: var(--width-n-half-half);
}
.key-three {
	width: calc(100% / 15 * 2.75);
}
.space {
	width: calc(100% / 15 * 6);
}
.key-inner {
	background: rgb(0,0,0);
	background: radial-gradient(circle, rgba(31,31,31,1) 0%, rgba(19,19,19,1) 100%);
	position: absolute;
	top: 2px;
	right: 2px;
	bottom: 2px;
	left: 2px;
	border-radius: 5px;
	border: 2px solid #111;
	border-top: 1px solid #333;
	border-bottom: 4px solid black;
	perspective: 500px;
}
.active .key-inner {
	border: 1px solid #111;
	border-top: 1px solid #2c2c2c;
	border-bottom: 2px solid black;
	background: #0e0e0e;
	display: flex;
	justify-content: center;
	align-items: center;
}
.active .key-inner::after {
	content: '\f577';
	font-family: 'Font Awesome 5 Free';
	font-weight: 600;
	font-size: 30px;
	color: #4444;
}


* {
  -webkit-user-select: none;  /* Chrome all / Safari all */
  -moz-user-select: none;     /* Firefox all */
  -ms-user-select: none;      /* IE 10+ */
  user-select: none;          /* Likely future */     
}

.f-span:after, .j-span:after {
	content: '';
	height: 3px;
	width: 15px;
	border-top: 1px solid #2c2c2c;
	border-radius: 5px;
	background: #0f0f0f;
	position: absolute;
	bottom: -5px;
	left: 50%;
	transform: translate(-50%, 0);
}
              
            
!

JS

              
                $( function() {
	$('.keys').each(function(){
		var self = this;
		$(self).append('<div class="key-inner"></div>');
	});
	
	$(document).on('click', '.caps', function() {
		$('.caps').toggleClass('caps-on');
	});

	$(document).on({
		mousedown: function() { $(this).toggleClass('active'); },
		mouseup: function() { $(this).toggleClass('active'); }
	}, '.keys');

	var key;
	var iskeydown = false;
	$(window).on({
		keydown: function(e) {
			e.preventDefault();
			// prevent from firing multiple times
			if (!iskeydown) {
				var code = e.which; // which key is pressed
				// find the key of which its data-key attribute is equal to "code"
				key = $('.keyboard').find('.keys[data-key="'+code+'"]');
				key.addClass('active');

				// if the key pressed is CapsLock, we toggle the caplock "light"
				if (code == 20) {
					key.toggleClass('caps-on');
				}
				iskeydown = true;
			}
		},
		keyup: function(e) {
			// remove the active class so that keys don't stay pressed
			iskeydown = false;
			$('.keys').removeClass('active');
		}
	});
});


  

              
            
!
999px

Console