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 8919845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:07:32+00:00 2026-06-15T06:07:32+00:00

How could one check whether the SHIFT key is currently being held while in

  • 0

How could one check whether the SHIFT key is currently being held while in the Linux console? By the Linux console I mean the real text/framebuffer one, not an xterm.

Preferably with only the built-in/standard shell commands, if possible.

  • 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-15T06:07:34+00:00Added an answer on June 15, 2026 at 6:07 am

    There is no command that I know of that gets the shift state of the keyboard. That said, looking at console_ioctl(4), there is a ioctl request for that: TIOCLINUX, subcode=6.

    So you could write a simple C program:

    #include <stdio.h>
    #include <stdlib.h>
    
    #include <sys/ioctl.h>
    
    int main()
    {
        char shift_state;
    
        shift_state = 6;
        if (ioctl(0, TIOCLINUX, &shift_state) < 0) {
                perror("ioctl TIOCLINUX 6 (get shift state)");
                exit(1);
        }
        printf("%x\n", shift_state);
        return 0;
    }
    

    The result can be interpreted in accordance to /usr/src/linux/include/linux/keyboard.h:

    #define KG_SHIFT        0
    #define KG_CTRL         2
    #define KG_ALT          3
    #define KG_ALTGR        1
    #define KG_SHIFTL       4
    #define KG_KANASHIFT    4
    #define KG_SHIFTR       5
    #define KG_CTRLL        6
    #define KG_CTRLR        7
    #define KG_CAPSSHIFT    8
    

    The above is a shift amount, so Shift is 1, AltGr is 2, Ctrl is 4, and so on.

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

Sidebar

Related Questions

Could any one give me an idea to check whether a string is null
I want to create one so that I could check whether a certain word
How could one test whether a set of modules is installed, given the names
Could one help translating following sed command so it does the same on aix
Problem in short: How could one implement static if functionality, proposed in c++11, in
When adding a new Entity Framework object to a database, how could one have
could someone one the current list of managed Beans or classes in Java EE
Could any one tell me how to enable SOCKET support in PHP ?
Could some one guide me to create a APS logon token in .Net programmatically?
Could any one please tell me the meaning of ++ with array in the

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.