Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <!DOCTYPE html>
By Kamyar Lajani
	<title>Key game</title>
	<button onclick="startGame();">Start game</button>
	<h4>Your total points: 0</h4>
	<div id="gameover">
			<h2>Game Over!</h2>
			<p id="points"></p>
			<a href="index.html">Play again!</a>
	<div class="redline"></div>




                span {
			color: orange;
			text-shadow: 3px 0px 3px black;
			display: block;
			font-size: 200%;
			text-align: center;
			display: table;
			padding: 5px 15px;
			border: 1px solid orange;
			border-radius: 100%;
		#gameover {
			width: 100%;
			height: 800px;
			background-color: gray;
			position: absolute;
			top: -90px;
			left: -5px;
			display: none;
		#gameover div {
			padding: 20px 20px;
			width: 200px;
			border: 1px solid black;
			display: table;
			text-align: center;
			position: absolute;
			top: 30%;
			left: 40%;
			font-family: arial;
			box-shadow: 0px 0px 3px black;

		#gameover div a {
			text-decoration: none;
			padding: 5px 5px;
			border: 1px solid black;
			color: orange;
		.redline {
			position: absolute;
			border-top: 2px solid red;
			top: 570px;
			width: 98%;


                function startGame() {
			var arr = [];
			var char = 'a';
			var points = 0;
			for(let i=0; i<26; i++) {
				arr[i] = String.fromCharCode(char.charCodeAt() + i);
			var on = 1, random, randomPosition;
			var element, elementLength;
			function randomly() {
				 element = document.getElementsByTagName("span");
				 elementLength = element.length;
				 let i = 0, arrayLength = arr.length, random;
				if(elementLength >= 10) {
						on = 0;
				else if(i < arrayLength) {
					random  = Math.floor(Math.random() * arrayLength);
					randomPosition  = Math.floor(Math.random() * (80-20)) + 20;
					document.body.innerHTML += `<span style="margin-left:${randomPosition}%">${arr[random]}</span>`;
				if (on==1) {
					setTimeout(randomly, 600);
				else {
					document.getElementById("gameover").style.display = "block";
					document.getElementById("points").innerHTML = `Your total points: ${points}`;

			 document.onkeyup = function(event) {
					for(let i=0; i< elementLength; i++) {
						if(element[i].innerHTML === event.key) {
							document.getElementsByTagName("h4")[0].innerHTML = `Your total points: ${points}`;