Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8455015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:10:38+00:00 2026-06-10T12:10:38+00:00

Alright, before this gets flagged as a possible duplicate, I’ve already tried the following

  • 0

Alright, before this gets flagged as a possible duplicate, I’ve already tried the following code:

Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)

And it is always returning false for me [see below]. Could someone confirm if this is supposed to be working, and I’m misusing it, or if it’s known to be broken? If it is in fact broken, does anyone have a better method to use?

EDIT:

Alright, just found out something more. It appears to just return what it was at the begining of my programs launch. If I start the program with it on, it says its on, and vice versa. Here’s my code:

while (true) {
    boolean isOn = Toolkit.getDefaultToolkit().getLockingKeyState(
        KeyEvent.VK_CAPS_LOCK);
    System.out.println("Caps lock is now: " + (isOn ? "ON" : "off"));
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
}

And that’s just always printing out whatever it started as

(ex. if I start with caps lock on, even if I toggle it off right after, it prints:

Caps lock is now: ON

Caps lock is now: ON

Caps lock is now: ON

Caps lock is now: ON

etc., if I start with it off, it will print off no matter what)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:10:40+00:00Added an answer on June 10, 2026 at 12:10 pm

    Poking around, I think getLockingKeyState() might be broken.

    You could try KeyboardUtils, but it looks like that means you have to carry JNA overhead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I know this question has been asked before, but mine has a different
Alright, I'm not sure if this question has been asked before so if it
Alright, so I got this code for gluLookAt: lookAt = new Vector3f(-player.pos.x, -player.pos.y, -player.pos.z);
Alright so I just tried to cut down on lines of code by changing
Possible Duplicate: How can I remove external links from HTML using Perl? Alright, i'm
Alright, I have the following: wchar_t **filePathList; This holds a list of files that
Alright, so I am having some issues. Here is my code (opendir() called before
Alright, I am sure this question is asked before and I searched the forum
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright, this is driving me nuts because my regex is working on Rubular, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.