This article is the sequel to How to check if a character is lowercase in Javascript, which tells how to know if a character is lowercase.
As we have seen, the corresponding number codes for characters are referred to as event.charCode
property of a key on your keyboard, when an event
of keypress
is attached to the keys on your keyboard.
event.charCode
propertyThis property allows us to know the value of a character or key on your keyboard. As we saw from the preceding article, characters that are uppercase can be known through their ranges.
See an example below:
The JavaScript code that does the function above is shown below:
document.getElementById("char").addEventListener("keypress", (event) => {document.getElementById("code").innerText =`character ${event.key} = code ${event.charCode}`})
Uppercase characters have their range from 65 - 90.
This means that characters that do not fall within this range are not uppercase, and this determines which character is uppercase.
In the JavaScript code above, we checked if the event.charCode
falls within the range of 65-90. This tells if the character entered is UPPERCASE or not.