-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
19 lines (14 loc) · 670 Bytes
/
main.js
File metadata and controls
19 lines (14 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const userInput = document.querySelector(".input");
const pressedKeys = document.querySelector(".pressedKeys");
const remainingKeys = document.querySelector(".remainingKeys");
userInput.addEventListener("keyup", () => {
keyPressCounter();
});
keyPressCounter = () => {
pressedKeys.innerHTML = userInput.value.length;
remainingKeys.innerHTML = userInput.getAttribute("maxLength") - userInput.value.length;
//You can also use below logic, 50 is pre-set number for No. of Remaining Keys
//remainingKeys.innerHTML = 50 - userInput.value.length;
}
keyPressCounter();
//Use this Fuctioncall for set Pressed Keys to Zero on Refresh