How to Get a Notification When Caps Lock or Num Lock Is Enabled in Ubuntu

00_lead_image_lock_keys_indicator

If you’ve accidentally turned on Caps Lock too many times–we’ve all been there–here is a solution. You can add an indicator to the top panel that shows the status of the Caps Lock, Num Lock, and Scroll Lock keys, that notifys you when one of them is pressed.

RELATED: How to Disable or Reassign The Caps Lock Key on Any Operating System

Sure, you could disable or reassign the Caps Lock key, but if you use it occasionally, this is the next best thing. You only need to install a small app called Indicator Keylock.

To begin, we’re going to add the repository that contains the Indicator Keylock program. To do that, press Ctrl+Alt+T to open a Terminal window. Then, type the following command at the prompt and press Enter:

sudo add-apt-repository ppa:tsbarnes/indicator-keylock

Type your account password when prompted and press Enter again.

01_adding_repository

Press Enter when prompted to continue adding the repository.

02_press_enter_to_continue_adding_repository

Once the repository has been added, type the following command and press Enter to make sure the indicator-keylock package is up to date, as well as all other packages.

sudo apt update

03_updating_repository

Now, we’ll install the indicator-keylock program. Type the following command at the prompt and press Enter.

sudo apt install indicator-keylock

Enter your password, if prompted.

04_installing_indicator_keylock

When asked if you want to continue, type y and press Enter.

05_do_you_want_to_continue

When the installation is finished, either type exit at the prompt and press Enter, or click the “X” button in the upper-left corner of the Terminal window to close it.

06_closing_terminal

You must either log out and back in or reboot for the Indicator Keylock program to be added to the top panel. You’ll notice, at first, that you don’t see any indicator on the panel, even when you turn Num Lock on and off. But, you will see a notification box display below the top panel on the right side of the screen when you toggle Num Lock on or off.

07_num_lock_on_notification

However, when you turn Caps Lock on, not only do you see a notification, but you also see a red icon with the letter “A” on the top panel. The icon is red when Caps Lock is on.

08_caps_lock_on_notification

Only one icon displays on the panel, but you can choose which icon you want to display. Click on the A icon on the panel and select an icon from the drop-down menu.

09_selecting_icon_to_show_on_panel

The menu indicates which Lock keys are on by turning the icons on the menu red for the Lock keys that are currently on. For example, the image below indicates that the Num Lock key is the only Lock key that is currently on. Notice, however, that the icon on the panel is not red, even though the Num Lock key is on. There is a setting in the Preferences that allows you to specify which Lock key will turn the icon on the panel red and, by default, it’s initially set to the Caps Lock key. To change this setting, select “Preferences” from the drop-down menu.

10_selecting_preferences

Remember that, initially, there was no icon on the panel? The only way to get an icon on the panel was to turn on Caps Lock. Then, you can click the icon and change it or open the Preferences. You can choose to always display an icon on the panel whether any of the Lock keys are on or not. To do this, check the “Show indicator while lock key is inactive” box.

The Caps Lock, Num Lock, and Scroll Lock options on the Preferences dialog control which key being on will turn the indicator icon on the panel red. For example, I want the icon on the panel to turn red when the Num Lock key is on because my keyboard does not have an indicator for that key.

If you don’t want an indicator to show on the panel at all, even if any of the Lock keys are on, uncheck the “Use an application indicator” box.

11_preferences_dialog

Click “Close” to save your settings and close the Preferences dialog box.

I’ve selected Num Lock both on the dropdown list and on the Preferences dialog box. So, Indicator Keylock is now set up to show the Num Lock icon on the panel and for that icon to turn red only when the Num Lock key is on. If the Caps Lock or Scroll Lock keys are on, they will turn red on the drop-down menu, but won’t turn the icon on the panel red.

12_selecting_which_lock_key_causes_red

If you unchecked the “Use an application indicator” box on the Preferences dialog box, you may be wondering how to get the indicator back, considering there is no icon at all on the panel to click on so you can open the Preferences dialog box. No worries. You can still open the Preferences dialog box. Simply click the Dash button on the Unity launcher, or you can press the Super key on your keyboard (which is usually the Windows key on typical keyboards).

13_opening_dash

Start typing indicator in the search box at the top of the screen, until you see the Indicator-LockKeys icon display. Click on that icon to open the Preferences dialog box. Then, you can check the “Use an application indicator” box again to have the indicator display when you turn on Caps Lock, as well as change the other settings on the Preferences dialog box.

14_opening_indicator_keys_preferences

When you change any of the settings in Indicator Keylock, they might not take effect immediately. You might have to toggle the affected Lock key a couple of times before the setting is applied.


Windows users can take advantage of similar tricks, too. In Windows, you can have the system play a sound or you can get a taskbar notification when any of these keys are pressed.

Lori Kaufman is a writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.