Remap Keys on your Keyboard in Linux

Поділитися
Вставка
  • Опубліковано 18 вер 2024
  • We look at how we can remap keys on your keyboard in Linux with Xorg, using xmodmap. In my example, I'll remap the Context Menu key to Right Super, since this key is missing on some keyboards, being replaced by a Function key for multimedia functions.
    1. Determine the keycode of the key you want to remap using this command:
    xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s
    ", $5, $8 }'
    2. Press the key you want to remap to obtain the keycode:
    135 Menu
    In this example, the keycode is "135" and the keysym is "Menu"
    3. In a text editor, enter this line:
    keycode 135 = Super_R
    4. Save the file in your home directory as:
    .Xmodmap
    (don't forget the dot "." at the beginning)
    5. To apply changes, either reboot or run this command:
    xmodmap .Xmodmap
    Note that if you hotplug your keyboard by unplugging and plugging it back in, you will need to reapply the changes with the above command.
    If you want to add comments to your .Xmodmap file, pre-append with "!" instead of "#".
    Examples of other keysyms are shown here:
    wiki.archlinux...
    Other articles I referenced in the the video were:
    wiki.archlinux...
    wiki.archlinux...
    Attributions:
    stainless-steel-keyboard-5-1550850 Photo by Andreas Just from FreeImages
    Contact me:
    Twitter: @sleepyeyesvince
    MeWe: mewe.com/i/sle...

КОМЕНТАРІ • 122

  • @tchogon4692
    @tchogon4692 2 роки тому +5

    Thanks mate. I searched a lot about remmaping keys on linux to make AltGr, Menu, R_CTRL and L_Shift work as the arrow keys but I only had found overly complicated ways to do this simple thing, which I tried but couldn't make it work because I'm a beginner at Linux as a whole.
    You just saved me some money, I was about to throw my new keyboard and grab a new one with dedicated arrow keys just because of that.
    [Worked on ZorinOS 16]

  • @frankdarwiche1471
    @frankdarwiche1471 3 роки тому +3

    Tom thank you so so so so much. I've been trying to do this for two weeks. I found all sorts of complicated tutorials that didn't work. I have laptop with some keys which went dead and I just needed to use F1 --- F 10 keys to replace them. Your method worked perfectly and seamlessly. Thank you again!!!

  • @hugooliveira7516
    @hugooliveira7516 4 роки тому +2

    Man, thanks for your help. I used to disable my "End" in Windows using KeyTweak program but i recently installed Ubuntu in my pc and i didn't know how to disable a key. As you probably know, it's impossible to do things, specially browsing, with "End" key pressed. I read lots of tutorials but yours was the one that most helped me.

    • @sleepyeyesvince
      @sleepyeyesvince  4 роки тому +1

      You are so welcome and your feedback gives me so much encouragement to keep learning and sharing. Also very glad to have you over into the Linux Community. It is the greatest.

  • @leopards8442
    @leopards8442 4 роки тому +4

    These tips works with Raspberry pi Os, thank you so much for sharing it Sir.

  • @somnvm37
    @somnvm37 2 роки тому +3

    The thing is, I need to replace a combination of two letters, so that when I press thrid level, and one letter, it's printing another character

  • @Sam_CL350
    @Sam_CL350 3 роки тому +3

    Would it be possible using this method to program the Super key to do two key commands? Example, Alt R
    Thanks

    • @Haitch_1_
      @Haitch_1_ 2 роки тому +2

      Hey, it's been 5 months. And I have a similar problem. Have you found a solution?

  • @srijan4622
    @srijan4622 3 роки тому +3

    I believe this does not work anymore. In fact, xmodmap has been deprecated for quite a while now (before the video was originally posted). We need to use the newer xkb.
    For me using xmodmap randomly resetted my settings in between sessions.

    • @davidoyinbo4591
      @davidoyinbo4591 3 роки тому

      It still works. I just used it to disable my caps_lock key because it was clicking by itself

    • @killertigergaming6762
      @killertigergaming6762 2 роки тому

      As far as im aware xmodmap isn't deprecated and you have to make it autolaunch in your .bashrc or something else for it to stay consistent

  • @saadmansakib
    @saadmansakib Рік тому

    Thank you so so much mate!
    I was desperately seeking for this solution but couldn't find any useful tutorial.
    But now it works perfectly!🤝

  • @StrangeIndeed
    @StrangeIndeed 4 роки тому +1

    I'm currently configuring minimal Arch and this helped me a lot. Thanks c:

  • @araujotoy
    @araujotoy 2 роки тому

    I'm very grateful for your help! I was thinking about getting a new pc but with this resource I can keep it, thank you so much!

  • @hieudz1297
    @hieudz1297 2 роки тому

    THANK U SO SO SO SO MUCH SUCH LIFE SAVER , i've read a lot of docs tutorial but hardly understand any , luckily i found ur easy to grasp tutorial

  • @motoryzen
    @motoryzen Рік тому

    1:25 to 1:40 read command also works
    Type it. Press enter. THEN press the key you're wanting to see the result of,

  • @tibofordeyn1529
    @tibofordeyn1529 3 роки тому +4

    use xmodmap for this!
    xmodmap -e "keycode 151=less"
    that's an example of how you can do it in 1 command

    • @helvetica-bold697
      @helvetica-bold697 2 роки тому +2

      Lifesaver. Thank you!

    • @roymath
      @roymath Рік тому

      That’s useful for trying out things. But it won’t persist between different X11 sessions.

    • @tibofordeyn1529
      @tibofordeyn1529 Рік тому +1

      @@roymath I think you could put it in your xinitrc file and make it permanent

  • @grosses_wassertier666
    @grosses_wassertier666 2 роки тому +3

    you need to clear the key first.
    for example, if you want to reassign alt to super:
    clear mod1
    keycode 64 = Super_R

  • @segioaweog1993
    @segioaweog1993 3 роки тому

    Thank you for the explanation! My mechanical keyboard is starting to fail and this is so handy while trying to fix it!

    • @sleepyeyesvince
      @sleepyeyesvince  3 роки тому +1

      Glad it helped! Is there a way you can replace the switch that's failing on your keyboard?

    • @segioaweog1993
      @segioaweog1993 3 роки тому

      @@sleepyeyesvince well, I've watched a lot of UA-cam videos about it and yes, it is possible, but I have to use the solder for that. It could be an option if more keys fail in the future, but for the moment I'm fine with that. I'm afraid to break the keyboard and mess it all up hahaha

  • @democracybacksliding
    @democracybacksliding 11 місяців тому

    I pretty sure I will be able to follow your video
    So thank you for making tutorials !!
    finally a reasonable soultion for key mapping

  • @guilhermealbertodemoraes7970
    @guilhermealbertodemoraes7970 3 роки тому

    It works great! Turns out I have a Asus S451LA and it has the VIVO key, which is useless in my Ubuntu Histrute. Aldought i did map it with the F13 key, and now I use it to toggle Guake. Thank you very much.

  • @ivanpedromuricy
    @ivanpedromuricy 5 місяців тому

    Very nice tutorial. Thank you !!!

  • @black-purple-dev
    @black-purple-dev 3 роки тому

    Thank you so much I really thought that I have to go through some badass config. But you explained it i literally seconds. good job!!

  • @sandem4592
    @sandem4592 3 роки тому

    Thank you for the easy to follow tutorial!

  • @GIULI4994
    @GIULI4994 2 роки тому

    thanks a lot for this thorough guide!

  • @gimpysticks
    @gimpysticks 4 роки тому

    Another great video Vince!

  • @xXrandom
    @xXrandom 5 місяців тому

    This helped me tons 😇

  • @koofejood
    @koofejood Рік тому

    This video gave me a clue to remap keys on linux. Great. But I am just starting to use Linux mint recently. I use Windows 11 before. I am still facing the problem which are: I always remap [insert] and [prt sc] as [up] and [down] arrows with microsoft powertoys. Now up works fine but down[prt sc] drags the text line down a line which is not intended and I want simply down the cursor a line. And [caps_lock] to [Escape] works but [caps_lock] action is still bundled with [escape] action. The only thing working flawlessly is [context_menu] to [Super_R]. Thanks.

  • @zakur0hako
    @zakur0hako Рік тому +1

    wow this was easy thanks a lot!

  • @heberjimenezmendez6561
    @heberjimenezmendez6561 3 роки тому

    gracias amigo, despues de dos dias de investigar al fin encontre la solucion.... thanks

  • @guilhermebertholuiz1560
    @guilhermebertholuiz1560 4 роки тому +1

    I really liked your video, but suppose that I wanted to change some combination of keys lik fn + ' for another letter or symbol is that possible ?

    • @sleepyeyesvince
      @sleepyeyesvince  4 роки тому +1

      From what I understand, the Fn+? key combination is an internal function that is specific to keyboard model to call up special tasks like your multimedia keys. Unfortunately they do not appear to be re-mappable that I am aware of.

    • @guilhermebertholuiz1560
      @guilhermebertholuiz1560 4 роки тому

      @@sleepyeyesvince thanks Ive being using other ways to type the things that are not on the keyboard, is kind of hassle but the best I`ve could come up with, hope someday someone find a way to do that easily

  • @Aman-jo5rm
    @Aman-jo5rm 4 роки тому +1

    For linux mint, if it doesn't work, type this command after creating the file
    *xmodmap ~/.Xmodmap*

  • @SweetTodd
    @SweetTodd 4 роки тому +1

    Got this Error;
    xmodmap: unable to open file './Xmodmap' for reading
    xmodmap: 1 error encountered, aborting.

    • @sleepyeyesvince
      @sleepyeyesvince  4 роки тому

      I wonder if that sounds like an error in the syntax somewhere in your .Xmodmap file. As reference, my one has as it's contents:
      keysym Menu = Super_R
      !keycode 135 = Super_R
      (Note the "!" is how you comment out a line)

    • @leopards8442
      @leopards8442 4 роки тому

      I also had this error,
      Try adding xmodmap ./.Xmodmap just to be sure.

    • @Aman-jo5rm
      @Aman-jo5rm 4 роки тому

      type this command in terminal instead
      *xmodmap ~/.Xmodmap*

    • @dhaloh
      @dhaloh 3 роки тому

      I get this too:
      xmodmap: unknown command on line /home/user/.Xmodmap:1
      xmodmap: 1 error encountered, aborting.

    • @austinjames5516
      @austinjames5516 3 роки тому

      just type this instead:
      xmodmap .Xmodmap

  • @PoulJulle-wb9iu
    @PoulJulle-wb9iu 3 роки тому +1

    what if i want to map a combination, say ctrl+alt -> alt gr?

    • @sleepyeyesvince
      @sleepyeyesvince  3 роки тому

      I don't think this would work for key combinations unless the particular combination outputs a specific keycode. Good luck!

  • @thoropyt9955
    @thoropyt9955 11 місяців тому

    Thank you very much 👍

  • @user-ug6mj3cn8c
    @user-ug6mj3cn8c 2 місяці тому

    works on AntiX to replace the Enter key as the Acer R7 571 keyboard stops working over time.. thanks!

  • @BeastMode070subscribe
    @BeastMode070subscribe 2 роки тому

    When I remapped the caps lock key to work as backspace, both the caps lock and backspace keys take an input. How do I make it such that only backspace is registered and not caps lock. Great video btw!

  • @glddiggers7176
    @glddiggers7176 2 роки тому

    Thank you so much!!! You're a life saver!!!

  • @Spoonuk666
    @Spoonuk666 Рік тому +1

    Can a single key be re-mapped to two keys for example, key '1' to be re-mapped to a combination of 'SHIFT+F12' ?

    • @user-ug6mj3cn8c
      @user-ug6mj3cn8c 2 місяці тому

      did you ever make it happen

    • @Spoonuk666
      @Spoonuk666 2 місяці тому

      @@user-ug6mj3cn8c Sadly not :(

    • @zoro_065
      @zoro_065 5 днів тому

      @@user-ug6mj3cn8c i am looking for the same man, lemme know if you found any solutions to it, thanks

  • @SagvanKurdi
    @SagvanKurdi 2 роки тому

    Thank you, it worked

  • @pavelmorales5491
    @pavelmorales5491 4 роки тому +1

    Thanks, just one thing It doesn’t work after reboot, need to run xmodmap .Xmodmap again. Any solution?

    • @ego-qx1wv
      @ego-qx1wv 4 роки тому

      x2

    • @sleepyeyesvince
      @sleepyeyesvince  4 роки тому

      I'd suggest perhaps adding xmodmap .Xmodmap to your ~/.xsession file or however your DE runs startup scripts?

    • @learnitfaster3139
      @learnitfaster3139 3 роки тому +1

      @@sleepyeyesvince how can we do that please?

  • @oliversepulveda4426
    @oliversepulveda4426 2 роки тому

    Thank you very much! Now I can basically used my keyboard hahaha

  • @DonHenderson
    @DonHenderson 4 роки тому +1

    Nice one mate, :)

  • @mpw621
    @mpw621 Рік тому

    Very helpful !

  • @Aashik01
    @Aashik01 24 дні тому

    Thanks bro

  • @shuvojyotirakshit5808
    @shuvojyotirakshit5808 4 роки тому

    thanks, brother, you solved my biggest issue

  • @nekoill
    @nekoill Рік тому

    That one person who actually does use the menu key rather frequently. Let me explain myself. It's actually just that same instinct that makes one deliberately go for programs that, say, support Vim-stule motions and such; just the same way, if I have a context menu button neatly under my pinky, why would I even bother reaching out for my mouse,?

  • @Cookiekeks
    @Cookiekeks 3 роки тому +1

    Thanks man

    • @sleepyeyesvince
      @sleepyeyesvince  3 роки тому

      Thanks for watching and taking the time to leave a comment.

  • @matthewjones2190
    @matthewjones2190 3 роки тому

    What do you write in nano when a key has two options (1: primary 2: shift option)? My laptop has the same number for both for example: ‘20 minus’ ‘20 underscore’. I want to change the underscore to dollar. But writing this in nano would change minus to dollar:
    Keycode 20 = dollar
    Some help would be greatly appreciated. Thanks

    • @sleepyeyesvince
      @sleepyeyesvince  3 роки тому

      I don't think you can do that. When you remap a key, it will remap all the functions of that key, turning it completely into another.

  • @adasd2420
    @adasd2420 2 роки тому

    thx man
    very useful

  • @zmurilo19
    @zmurilo19 3 місяці тому

    thank you so much

  • @kennataddese4876
    @kennataddese4876 Рік тому

    Thanks!!

  • @boreuborea9368
    @boreuborea9368 Рік тому

    Is there any way to map an HP omen laptop and his macro keys ?

  • @AnimeThrones
    @AnimeThrones 2 місяці тому

    I tried with esc key and didn't work 😅

  • @apurbasaha6818
    @apurbasaha6818 2 роки тому

    Thank you so much sir

  • @unity3dconcepts434
    @unity3dconcepts434 2 роки тому

    Neat.. But my laptop lacks proper HOME and END keys. These keys are only available when I disable numpad. I want FN+7 as HOME and FN+9 as END how to do that? How to make key combinations work in .Xmodmap? I see FN is not recognised as a keycode. I can use CTRL instead, but how to do key combinations?

    • @motoryzen
      @motoryzen Рік тому

      If you're using Linux mint, you can create a custom keyboard shortcut for that.
      Open gnome-terminal, type without quotes " read" press enter.
      Now press only the home button after you have disabled you numpad.
      Now make a note of exactly what the results are.
      Do the same.peocess again but ensure the numpad is enabled.
      Are the results the same?
      if they are not..my idea should work for you.
      You'll enter that result you get from that terminal command as the command in the command window part when you select " custom shortcut". Then for the keyboard shortcut combo do Fn+7.
      You could also do Shift+numpad 7 I think. 🤔.

  • @anujsharma2377
    @anujsharma2377 Рік тому

    Hello, is there a way to identify the keysym of a key that isn't working ? Please help.

    • @Kathe-rk3xq
      @Kathe-rk3xq 8 місяців тому

      just google it, geez!

  • @azispratama92
    @azispratama92 Рік тому

    hello is there any tutorial to disable specific keyboard keys using xmodmap ?

  • @choobinv
    @choobinv 5 місяців тому

    thanks a lot

  • @anshraj5916
    @anshraj5916 Рік тому

    you are a god

  • @apurbasaha6818
    @apurbasaha6818 2 роки тому

    SIR, HOW CAN I REGISTER '#' SYMBOL WHEN THE 3 KEY IS NOT WORKING?

  • @duynguyenphuong6486
    @duynguyenphuong6486 2 роки тому

    I wrote this to disable my PageDown key and change PageUp to Down arrow. But I can't do it. I tried to find the.Xmodmap file but I cant find it in Home
    keycode 117=
    keycode 112= Down

    • @RowingGameDev
      @RowingGameDev 2 роки тому

      I think you just need to make your own .Xmodmap file in Home, that's what I did

  • @Insomniac_Insights
    @Insomniac_Insights 3 роки тому

    help me.
    i want to change this key to this
    z to [
    x to ]
    b to \
    how can I do this?

  • @Aman-jo5rm
    @Aman-jo5rm 4 роки тому

    Please help. Buddy can you tell me the keysym for Fn key , I am unable to find it.
    Similar to point no. 3 in description, I need a code to change my super_L to fn key.

    • @sleepyeyesvince
      @sleepyeyesvince  4 роки тому

      Sorry, I don't thing this mod will work for a Fn key. Your keyboard's Fn key is specific only to your model of keyboard to allow it to access extra functions. As such, by itself, the Fn key does not send any input data to your computer.

  • @HakkiOgrt
    @HakkiOgrt 6 місяців тому

    thnx

  • @ardiansyahs1739
    @ardiansyahs1739 Рік тому

    not simbol ?

  • @andrehoffman6887
    @andrehoffman6887 3 роки тому

    How can I make this change permanent? I get it successfully only if type xmodmap .Xmodmap on terminal. Thanks!

    • @sleepyeyesvince
      @sleepyeyesvince  3 роки тому +1

      On my system, it seems to apply automatically each time I login if using xorg. Otherwise, a solution could be placing it into a startup script or into your ~/.profile for example.

  • @JoshPaulie
    @JoshPaulie 3 роки тому +1

    Simple! :)

  • @chrinamint
    @chrinamint Рік тому

    I converted my Chromebook to a Linux machine so I want to remap some of these Chromebook functions to regular functions and I can only do a few because a few are automatically listed in The keyboard shortcut setup place but I want to change a couple that are not listed and I don't know how to do those. For example on a Chromebook above the shift key where normal keyboards are caps lock they have a little magnifying glass and it's either a search key or opens a menu box but I want to make it a normal caps lock button and I don't know how to do that. I also do not have a delete key and I want to make something be a delete key and I don't know how to do that either. So I found this video and I'm going to check it out but I don't have access to the internet right now to follow. But I'm going to come back to this and check it out when I get home. Hopefully I can make it work!

  • @motoryzen
    @motoryzen Рік тому

    Good man..I appreciate your video BUT... PLEASE... ZOOM in.. on a phone or tablet.its very difficult to read what you're typing or pasting...even on a 1440 phone

  • @zeldroid42
    @zeldroid42 3 роки тому

    does ubuntu use xmodmap

  • @137950201
    @137950201 3 роки тому

    Hi I want ctrl + alt + left arrow for Home and right for End pls help on same

    • @sleepyeyesvince
      @sleepyeyesvince  3 роки тому

      Sorry, I don't think this method works for key combinations :(

  • @TD-ph3wb
    @TD-ph3wb 3 роки тому

    doesnt work with alt :(

  • @thenub8532
    @thenub8532 2 роки тому

    For me doesent work on reboot

  • @erkin8657
    @erkin8657 3 роки тому

    how do we undo that key mapping tho

    • @sleepyeyesvince
      @sleepyeyesvince  3 роки тому

      Simply delete your .Xmodmap file from your home directory.

  • @dhaloh
    @dhaloh 3 роки тому

    I get an error.

  • @InFamousD147
    @InFamousD147 2 роки тому

    It’s remapping

  • @jinitescapematrix
    @jinitescapematrix 3 роки тому

    thank you so much