{"id":61952,"date":"2024-01-09T21:38:05","date_gmt":"2024-01-09T20:38:05","guid":{"rendered":"https:\/\/ekiwi-blog.de\/61952\/linux-remap-keys-key-missing-on-new-keyboardinux-key-remapping\/"},"modified":"2024-01-12T11:22:45","modified_gmt":"2024-01-12T10:22:45","slug":"linux-remap-keys-key-missing-on-new-keyboardinux-key-remapping","status":"publish","type":"post","link":"https:\/\/ekiwi-blog.de\/en\/61952\/linux-remap-keys-key-missing-on-new-keyboardinux-key-remapping\/","title":{"rendered":"Linux: Remap keys, < key missing on new keyboard"},"content":{"rendered":"<p>Remap keys in Linux.<\/p>\n<p><!--more--><\/p>\n<p>My new keyboard has an American layout. Since I type blind, no problem so far, but the key for &lt;, &gt; and | is missing. The problem is that it&#8217;s not somewhere else, it&#8217;s missing.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ekiwi-blog.de\/wp-content\/uploads\/2024\/01\/tastatur_1.jpg\" alt=\"\" width=\"1000\" height=\"375\" class=\"aligncenter size-full wp-image-61948\" srcset=\"https:\/\/ekiwi-blog.de\/wp-content\/uploads\/2024\/01\/tastatur_1.jpg 1000w, https:\/\/ekiwi-blog.de\/wp-content\/uploads\/2024\/01\/tastatur_1-300x113.jpg 300w, https:\/\/ekiwi-blog.de\/wp-content\/uploads\/2024\/01\/tastatur_1-768x288.jpg 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p><strong>What to do?<\/strong><\/p>\n<p>My idea was to use a different button for this. One button that would work well for this is the Caps Lock button. I don&#8217;t use it anyway and I think the key is superfluous anyway.<br \/>\nThe solution was quite simple under Windows, where I could simply reconfigure the key with &#8220;<a href=\"https:\/\/ekiwi-blog.de\/21598\/tastaturlayout-veraendern-mit-keytweak\/\">KeyTweak<\/a>&#8220;. That was done in 5 minutes.<\/p>\n<p>Linux is a bit more challenging. Here there is the software &#8220;<a href=\"https:\/\/wiki.ubuntuusers.de\/Xmodmap\/\">Xmodmap<\/a>&#8220;. This can in principle reconfigure keys, but has a few limitations, more on this later.<\/p>\n<p>First we create the configuration data:<\/p>\n<pre>\r\nvim .\/Xmodmap\r\n<\/pre>\n<p>Here is the content of the file, please note this is the german layout:<\/p>\n<pre>\r\nclear Lock\r\nkeycode 108 = Mode_switch Mode_switch Mode_switch Mode_switch\r\nkeycode 66 = less greater bar bar\r\nkeycode 24 = q Q at\r\nkeycode 26 = e E EuroSign\r\nkeycode 35 = plus asterisk asciitilde\r\nkeycode 11 = 2 quotedbl twosuperior\r\nkeycode 12 = 3 section threesuperior\r\nkeycode 16 = 7 slash braceleft\r\nkeycode 17 = 8 parenleft bracketleft\r\nkeycode 18 = 9 parenright bracketright \r\nkeycode 19 = 0 equal braceright \r\nkeycode 20 = ssharp question backslash \r\n<\/pre>\n<p>Let&#8217;s take a brief look at the content. With the first line we switch off the standard function of Caps-Lock. Otherwise, Caps-Lock is still activated additionally.<\/p>\n<p>The second line with the &#8220;Mode_switch&#8221; remaps the ALT-GR key. This is needed to get the | character. ALT-GR causes minor problems with Xmodmap.<\/p>\n<p>The third line then maps Caps-Lock to our desired characters. The syntax is normal, then with Shift and then the value for the modifier key.<\/p>\n<p>What do the other lines do? Well, reconfiguring ALT-GR has the side effect that the other characters generated with ALT-GR no longer work. These include the euro, at sign and the tilde. We therefore configure these keys with .<\/p>\n<p>We can determine the keycode with the &#8220;xev&#8221; command. Simply start this via the console and then press the key. The code is in the third line.<\/p>\n<pre>\r\nKeyRelease event, serial 38, synthetic NO, window 0x8600001,\r\n    root 0x3d0, subw 0x0, time 7427147, (1301,516), root:(1391,678),\r\n    state 0x10, keycode 35 (keysym 0x2b, plus), same_screen YES,\r\n    XLookupString gives 1 bytes: (2b) \"+\"\r\n    XFilterEvent returns: False\r\n<\/pre>\n<p>As soon as we have saved the file, we can activate it:<\/p>\n<pre>\r\nxmodmap ~\/.Xmodmap\r\n<\/pre>\n<p>Caps-Lock should be deactivated beforehand. If you have made a mistake and the configuration is rubbish, you can undo it with the following command.<\/p>\n<pre>\r\nsetxkbmap option\r\n<\/pre>\n<p>The setting is only valid until the next restart. It is therefore advisable to include the call for the setting in the <a href=\"https:\/\/ekiwi-blog.de\/27028\/linux-script-beim-login-ausfuehren\/\">login script<\/a>.<\/p>\n<p>So far it works quite well. I hope I haven&#8217;t overlooked an ALT-GR key, but this can otherwise be extended quite easily.<\/p>","protected":false},"excerpt":{"rendered":"<p>Remap keys in Linux.<\/p>\n","protected":false},"author":1,"featured_media":61945,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1555],"tags":[2754,1682,2443],"class_list":["post-61952","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-en","tag-keyboard-en","tag-linux-en","tag-linux-en-2"],"_links":{"self":[{"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/posts\/61952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/comments?post=61952"}],"version-history":[{"count":0,"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/posts\/61952\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/media\/61945"}],"wp:attachment":[{"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/media?parent=61952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/categories?post=61952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ekiwi-blog.de\/en\/wp-json\/wp\/v2\/tags?post=61952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}