- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The user interacts with a website to execute a functionality like hitting an API, handling clicks or buttons that trigger a method, and many more. In some of the cases, we might need to know whether the CAPS LOCK key is turned on or not.
Keyboard Event − In this type of Web API, the user interacts with the keyboard and the various events describe the kind of activity that occurs due to it.
Keydown Event − This is fired when a key is pressed.
KeyUp Event − This is fired when a key is released.
These events mainly occur from the keyboard that comes under the KeyboardEvent Object.
Modifier Keys: We also have modifier keys that are used in conjunction with other keys which perform some special purpose or shortcut to trigger the method. There are two types of Modifier Keys that are activated on pressing. For example, Shift, Ctrl, Alt, etc. Some other keys that activate locks on pressing include CAPS LOCK.
GetModifierState − We can use this method from the KeyboardEvent object that returns a Boolean when the modifier key is activated.
const isActive = event.getModifierState(keyString);
It will return a Boolean variable showing whether the key is activated or not.
In the script, we are simply extracting the input element that adds an event listener. Whenever an event is triggered, it reads the required details and returns the output.
When CapsLock is on there will be a warning “Warning: CapsLock Key is On!”
- Check if Caps Lock and Num Lock is on or off through Console in C#
- How to show the status of CAPS Lock Key in tkinter?
- How to detect pressing Enter on keyboard using jQuery?
- How to detect swipe vertically on a ScrollView using Swift?
- How to detect if a user is using an Android tablet or a phone using Kotlin?
- How to debug Lock wait timeout exceeded on MySQL?
- How to Lock Your Hard Drive on Windows OS?
- How to detect airplane mode is on or off in Android?
- How to detect which iOS version is running on the device?