Click here to Skip to main content
15,878,048 members
Articles / Ubuntu

Most Useful Key Missing? There is a Fix!

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
28 Oct 2020CPOL7 min read 11.8K   4   11
Solving the most annoying keyboard problem on Windows and Linux
Keyboards, especially laptop/notebook keyboards are bad! Very often, manufacturers remove some most important keys. At the same time, some keys are quite useless. This article shows the ways to remap the keys to make your keyboard more usable.


Typical Problems
What's Wrong with Context Menu Key?
Useless Keys


One day, I found that my memory is strongly motoric. If I have to use a keyboard that is not exactly like mine, it kills me. Even a shift of few millimeters in the position of the row of function keys can drive me crazy. The problem of the missing keys can appear on any keyboard. Using a separate keyboard device makes the problem relatively easy to solve. It’s not quite easy to buy a perfect keyboard conforming to some requirements, but I used to do it anywhere I worked. Laptops/notebooks are much harder to adapt to, and they typically have fewer keys, so missing the most useful one is more likely.

So, finally, I found a comprehensive solution for me. I use two kinds of systems regularly: Windows and a few Linux distros. For both, the solutions give identical results.

I think the most typical situation is missing the context menu key. This is not the only possible keyboard problem, but probably the hardest to tolerate.

Typical Problems

There are two sorts of possible problems: 1) a missing key, which we want to add, 2) a key which is not only useless but also annoying or confusing, triggering some function we would like to eliminate.

So, what we may want to do is to remap the keys to eliminate useless or annoying ones, and use these keys to assign the function of some missing keys to them. Let’s consider some examples.

What’s Wrong with Context Menu Key?

As I mentioned before, the most badly missing one is probably the context menu key. It keeps me amazed: why the manufacturers would eliminate this key? They do it more and more often.

As a matter of fact, many users don’t even notice the problem, as they use the right mouse button to access the context menu. However, the mouse key is not a good replacement for the key, as its behavior is radically different. The mouse action depends on the mouse pointer position, while the context menu activated based on the current selection, using it makes work a lot faster, as no precise mouse action is required.

Useless Keys

First of all, I would suggest eliminating Caps Lock. Anyway, who needs Caps Lock, ever?

In the past, these keys were used more frequently, when the all-caps style had some uses. These days, all-caps has only marginal application, moreover, using all-caps in Web communications is considered rude. The presence of this key is the permanent source of typing mistakes. Not only the remapping of this key can help to eliminate such annoying mistakes, but it can automatically improve politeness. :-)

More generally, I go in for more radical simplification and eliminate other toggle keys, just to avoid taking care of the current keyboard state. One important exclusion is the input method switch, for those who use more than one language. In particular, Num Lock can be eliminated. In practice, I don’t touch this particular key and remap the entire keypad to some fixed functions I need. Other people may want to remap Num Lock itself to give it some useful function.

Another example of a useless key is Print Screen. This is another badly obsolete function: no one actually prints a screen. Instead, the key is used to capture a screenshot. But screen capture is nothing but an application, which is not executed often, and it can be started in many other ways. Even for Windows, the Print Screen key is not the only way to capture a screen or an active window. For Windows 10, I would recommend newer features called “Screen Clip” and “Screen Sketch”. They are accessible through the URNs ms-screenclip: and ms-screensketch: used through a Web browser.

One can find more useless or inconvenient keys. Usually, this is something one can hit accidentally and disrupt current work: send the system to sleep, disconnect from Wi-Fi, and the like.



For Windows, the keys can be remapped in the system Registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout. For more detail, see, for example,

I would recommend a much safer solution: SharpKeys.exe.

The source code can be found here: This is a .NET application and can be built on most Windows systems without a need to use Visual Studio. It is configured to the .NET v.4.0 target but can be targeted to an early version down to v.3.5. For v.3.5, MSBuild comes with .NET framework, for later versions, it can be Visual Studio Build Tools, so the build can be done free of charge.

This application requests UAC confirmation to access the Registry, it helps to remap separate keys, and the result of remapping is applied on the system reboot.

Another option is using Microsoft Keyboard-Manager, part of PowerToys, available as an executable setup and the source code. However, I would still recommend the SharpKeys solution, as it is the most light-weight, presenting minimal requirements to the system.


On the laptop I installed Linux and completely solved the missing key problem for the first time, I wanted to remap not only Caps Lock, but two keys. That device has a Print Screen button where the context menu button is supposed to be located. So, in my example, I’ll show the remapping of both keys. Let’s say, in some shell script file we have:

xmodmap -e "clear Lock"
xmodmap -e "keysym Caps_Lock = Menu"
xmodmap -e "keysym Print = Menu"

In addition to the remapping of keys, we also need the first line which disables the normal Caps Lock behavior. If it wasn’t done, the second line would only remap Caps Lock to the context menu, then the key would do both: menu behavior and the switch of the Caps mode. The command “clear Lock” preserves the Caps_Lock symbol, so it can be used in the second line.

List of keysym names could be found, for example, here:

Note that not all documentation pages show all keysym names. I would advise searching by the keywords “list of keysym Linux”. Alternatively, execute xmodmap -pk to obtain the list of available symbols and associated numeric values.

Let’s say, the code above is placed in the file “”. It has to have “execute” attribute for all users. To test the operation, you can start it directly. Assuming the current directory is the same, you can use the code line:


However, this is not always suitable. To auto-start the execution, you may need to use an executable file, such as sh interpreter, then the command can be:

sh -c /path/to/

Alternatively, instead of a shell script file, nearly the same solution can be written in the form of a xmodmap data file:

clear Lock
keysym Caps_Lock = Menu
keysym Print = Menu

In this case, we also can use a single-line command. Assuming the above data is written in the file “fix-keyboard.xmodmap”, the command can be

xmodmap /path/to/fix-keyboard.xmodmap

This solution is shorter, but the solution with the shell script is better for debugging and can contain comments (lines starting with “#”).

Now, there is a little annoyance: if the command fixing the keyboard is executed more than once, it will show two errors on the second run. This is because two keysym commands remove the symbols, so they are not recognized on the second run. For example, it makes the command not quite suitable for adding it to the file “.bashrc”, because each additional terminal window will show the error. So, the comprehensive solution should be applied only to the user session startup.

Unfortunately, the session autostart customization can be achieved in different ways, moreover, the correct way depends on a particular Linux distro, desktop environment and window manager used, and other peculiarities. Please refer to the documentation of your system.

I’ll explain the autostart customization only by one example: Lubuntu with LXQt and Openbox, where the customization is well automated. In this case, the settings applet [Main Menu] => Settings => LXQt Settings => Session Settings => Autostart shows two sections: “Global Autostart” and “LXQt Autostart”, but the only difference is the option OnlyShowIn=LXQt; applied to “LXQt Autostart”. Use “Add” to create a new item and use one of the one-line commands described above. In both cases, some .desktop file is created in the directory “$XDG_CONFIG_DIRS/autostart” (~/.config/autostart by default) for a current user. To add a .desktop file to the autostart for all users, place it in the directory “$XDG_CONFIG_HOME/autostart” (/etc/xdg/autostart by default).

To do the same thing manually, learn Desktop Application Autostart Specification, the syntax of .desktop files, and their application.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
Physics, physical and quantum optics, mathematics, computer science, control systems for manufacturing, diagnostics, testing, and research, theory of music, musical instruments… Contact me:

Comments and Discussions

QuestionProgrammable keyboards are best. Pin
ssa-ed30-Oct-20 12:15
ssa-ed30-Oct-20 12:15 
AnswerRe: Programmable keyboards are best. Pin
Sergey Alexandrovich Kryukov30-Oct-20 14:00
mvaSergey Alexandrovich Kryukov30-Oct-20 14:00 
Questionalternate fix Pin
sasadler30-Oct-20 10:54
sasadler30-Oct-20 10:54 
AnswerRe: alternate fix Pin
Sergey Alexandrovich Kryukov30-Oct-20 14:36
mvaSergey Alexandrovich Kryukov30-Oct-20 14:36 
GeneralRe: alternate fix Pin
sasadler30-Oct-20 14:56
sasadler30-Oct-20 14:56 
GeneralPrint Screen is more useful than Context Menu, in my context at least. Pin
Julian Ragan30-Oct-20 7:45
Julian Ragan30-Oct-20 7:45 
AnswerRe: Print Screen is more useful than Context Menu, in my context at least. Pin
Sergey Alexandrovich Kryukov30-Oct-20 13:58
mvaSergey Alexandrovich Kryukov30-Oct-20 13:58 
GeneralPrint Screen is not useless Pin
Stepan Hakobyan30-Oct-20 2:41
professionalStepan Hakobyan30-Oct-20 2:41 
AnswerRe: Print Screen is not useless Pin
Sergey Alexandrovich Kryukov30-Oct-20 3:15
mvaSergey Alexandrovich Kryukov30-Oct-20 3:15 
QuestionThanks a lot Pin
Member 845631430-Oct-20 0:02
Member 845631430-Oct-20 0:02 
AnswerRe: Thanks a lot Pin
Sergey Alexandrovich Kryukov30-Oct-20 3:16
mvaSergey Alexandrovich Kryukov30-Oct-20 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.