ADVERTISEMENT

Keyboard Counter Using HTML,CSS and JavaScript

Telegram Group Join Now

ADVERTISEMENT

Keyboard Counter Using HTML,CSS and JavaScript

 

ADVERTISEMENT

Keyboard Hit Counter Using HTML,CSS and JavaScript
Keyboard Hit Counter Using HTML,CSS and JavaScript

ADVERTISEMENT

 

Welcome to the Codewithrandom blog. In this blog, we learn how to create a Keyboard Counter(when the user presses any key from the keyboard its counts and shows on the screen). We use Html, Css, and JavaScript for creating this Keyboard Hit Counter.

ADVERTISEMENT

I hope you enjoy our blog so let’s start with a basic Html Structure for a¬†Keyboard Hit Counter.

ADVERTISEMENT

HTML Code For Keyboard Counter

<div id="activity">
<img src="http://code.quirkbot.com/assets/images/logo/white-outline.svg" width="30%" alt="">
<h1 id="counter"><span class="hits">0</span>
<h1>Keys Hit</h1>
</div>

There is all the Html code for the Keyboard Hit Counter. Now, you can see output without Css and JavaScript. then we write Css and JavaScript for the Keyboard Hit Counter.

Portfolio Website Using HTML CSS And JAVASCRIPT ( Source Code)

Only Html Code Output

ADVERTISEMENT

Keyboard Hit Counter Using HTML,CSS and JavaScript
Keyboard Hit Counter Using HTML,CSS and JavaScript

CSS Code For Keyboard Counter

body {
margin: 0;
font-family: "Open Sans", comic-sans;
position: absolute;
width: 100vw;
height: 100vh;
overflow: hidden;
display: table;
}
#activity {
display: table-cell;
text-align: center;
vertical-align: middle;
}
#activity:before {
content: "Hit Any Key On Your Keyboard";
position: absolute;
top: -1;
left: 0;
width: 100vw;
height: 10vh;
background: rgba(10, 10, 10, 10, 10);
}
#activity:after {
content: "Codewithrandom";
position: absolute;
bottom: 0;
left: 0;
width: 100vw;
height: 12vh;
}
#result {
text-transform: uppercase;
}
a:link,
a:hover,
a:visited,
a:active {
text-decoration: bold;
}
.hits {
font-size: 5.75em;
font-weight: bolder;
}

Here is our updated output with Html and Css.

50+ Html ,Css & Javascript Projects With Source Code

Html + Css output

ADVERTISEMENT

Keyboard Hit Counter Using HTML,CSS and JavaScript
Keyboard Hit Counter Using HTML,CSS and JavaScript

JavaScript Code For Keyboard Counter

var hits = 0;
var hitElement = document.querySelector(".hits");
document.body.onkeyup = function (e) {
if ((e.keyCode == 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) {
addHit();
}
};
var addHit = function () {
hits++;
renderHits();
};
var renderHits = function () {
hitElement.innerHTML = hits;
};

Final Output Of Keyboard Hit Counter Html,Css and JavaScript

ADVERTISEMENT

Keyboard Hit Counter Using HTML,CSS and JavaScript
Keyboard Hit Counter Using HTML,CSS and JavaScript

 

 

100+ JavaScript Projects With Source Code ( Beginners to Advanced)

Now we have completed our Keyboard Counter. Here is our updated output with Html, Css, and JavaScript. Hope you like the Keyboard Counter Project. you can see the output video and project screenshots. See our other blogs and gain knowledge in front-end development.

Thank you!

In this post, we learn how to create a Keyboard Hit Counter using Html, Css, and JavaScript. If we made a mistake or any confusion, please drop a comment to reply or help you in easy learning.

ADVERTISEMENT

Written by РCode With Random/Anki 

ADVERTISEMENT

Codepen by –¬†Braxtoony

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Telegram Group Join Now

Share on:

Leave a Comment

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT