• About
  • Privacy Policy
  • Disclaimer
  • Contact
Soft Bliss Academy
No Result
View All Result
  • Home
  • Artificial Intelligence
  • Software Development
  • Machine Learning
  • Research & Academia
  • Startups
  • Home
  • Artificial Intelligence
  • Software Development
  • Machine Learning
  • Research & Academia
  • Startups
Soft Bliss Academy
No Result
View All Result
Home Software Development

Detect Caps Lock with JavaScript

softbliss by softbliss
May 14, 2025
in Software Development
0
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Anyone is capable of having their caps lock key on at any given time without realizing so. Users can easily spot unwanted caps lock when typing in most inputs, but when using a password input, the problem isn’t so obvious. That leads to the user’s password being incorrect, which is an annoyance. Ideally developers could let the user know their caps lock key is activated.

To detect if a user has their keyboard’s caps lock turn on, we’ll employ KeyboardEvent‘s getModifierState method:

document.querySelector('input[type=password]').addEventListener('keyup', function (keyboardEvent) {
    const capsLockOn = keyboardEvent.getModifierState('CapsLock');
    if (capsLockOn) {
        // Warn the user that their caps lock is on?
    }
});

I’d never seen getModifierState used before, so I explored the W3C documentation to discover other useful values:

dictionary EventModifierInit : UIEventInit {
  boolean ctrlKey = false;
  boolean shiftKey = false;
  boolean altKey = false;
  boolean metaKey = false;

  boolean modifierAltGraph = false;
  boolean modifierCapsLock = false;
  boolean modifierFn = false;
  boolean modifierFnLock = false;
  boolean modifierHyper = false;
  boolean modifierNumLock = false;
  boolean modifierScrollLock = false;
  boolean modifierSuper = false;
  boolean modifierSymbol = false;
  boolean modifierSymbolLock = false;
};

getModifierState provides a wealth of insight as to the user’s keyboard during key-centric events. I wish I had known about getModifier earlier in my career!

Request Metrics real user monitoring
Request Metrics real user monitoring
Request Metrics real user monitoring
Request Metrics real user monitoring
  • 39 Shirts – Leaving Mozilla

    39 Shirts – Leaving Mozilla

    In 2001 I had just graduated from a small town high school and headed off to a small town college. I found myself in the quaint computer lab where the substandard computers featured two browsers: Internet Explorer and Mozilla. It was this lab where I fell…

  • Conquering Impostor Syndrome

    Conquering Impostor Syndrome

    Two years ago I documented my struggles with Imposter Syndrome and the response was immense.  I received messages of support and commiseration from new web developers, veteran engineers, and even persons of all experience levels in other professions.  I’ve even caught myself reading the post…

  • Use Custom Missing Image Graphics Using MooTools

    Use Custom Missing Image Graphics Using MooTools

    Missing images on your website can make you or your business look completely amateur. Unfortunately sometimes an image gets deleted or corrupted without your knowledge. You’d agree with me that IE’s default “red x” icon looks awful, so why not use your own missing image graphic? The MooTools JavaScript Note that…

  • background-size Matters

    background-size Matters

    It’s something that makes all men live in fear, and are often uncertain of. It’s never spoken, but the curiosity is always there. Nine out of ten women agree in the affirmative. Advertisers do their best to make us feel inadequate but…


Tags: CapsDetectJavaScriptLock
Previous Post

How to Become Immortal Using AI? • AI Blog

Next Post

The doctor is out: PB Fintech's radical vision for Indian healthcare

softbliss

softbliss

Related Posts

Cosmos DB Disaster Recovery: Multi-Region Write Pitfalls
Software Development

Cosmos DB Disaster Recovery: Multi-Region Write Pitfalls

by softbliss
May 15, 2025
Coding Assistants Threaten the Software Supply Chain
Software Development

Coding Assistants Threaten the Software Supply Chain

by softbliss
May 14, 2025
Integration with Flexsin’s Microsoft ERP Consulting.
Software Development

Integration with Flexsin’s Microsoft ERP Consulting.

by softbliss
May 13, 2025
Software Development

Bard Is not Human

by softbliss
May 13, 2025
How to Choose the Right Drone Software Development Company?
Software Development

How to Choose the Right Drone Software Development Company?

by softbliss
May 12, 2025
Next Post
The doctor is out: PB Fintech's radical vision for Indian healthcare

The doctor is out: PB Fintech's radical vision for Indian healthcare

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Premium Content

How To Use AI Agents in Small Business

April 4, 2025
Medikabazaar CEO denies all allegations after ousted from Co for fraudulent activities

Medikabazaar CEO denies all allegations after ousted from Co for fraudulent activities

April 19, 2025
The Importance of Gathering Evidence Following a Car Accident

The Importance of Gathering Evidence Following a Car Accident

April 7, 2025

Browse by Category

  • Artificial Intelligence
  • Machine Learning
  • Research & Academia
  • Software Development
  • Startups

Browse by Tags

Amazon App Apr Artificial Berkeley BigML.com Blog Build Building Business Content Data Development Future Gemini Generative Google Guide Intelligence Key Language Large Learning LLM LLMs Machine Microsoft MIT Mobile model Models News NVIDIA Official opinion OReilly Research Software Startup Startups Strategies students Tech Tools Video

Soft Bliss Academy

Welcome to SoftBliss Academy, your go-to source for the latest news, insights, and resources on Artificial Intelligence (AI), Software Development, Machine Learning, Startups, and Research & Academia. We are passionate about exploring the ever-evolving world of technology and providing valuable content for developers, AI enthusiasts, entrepreneurs, and anyone interested in the future of innovation.

Categories

  • Artificial Intelligence
  • Machine Learning
  • Research & Academia
  • Software Development
  • Startups

Recent Posts

  • Harnessing AI for a Sustainable Earth Day
  • Cosmos DB Disaster Recovery: Multi-Region Write Pitfalls
  • StreamBridge: Turning Your Offline Video Large Language Model into a Proactive Streaming Assistant

© 2025 https://softblissacademy.online/- All Rights Reserved

No Result
View All Result
  • Home
  • Artificial Intelligence
  • Software Development
  • Machine Learning
  • Research & Academia
  • Startups

© 2025 https://softblissacademy.online/- All Rights Reserved

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?