Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Linux
  3. Changing key mapping with xmodmap is broken. Is there a workaround?

Changing key mapping with xmodmap is broken. Is there a workaround?

Scheduled Pinned Locked Moved Linux
linux
2 Posts 2 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C This user is from outside of this forum
    C This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1

    I want to change the key mapping of Shift+Backspace to Delete.

    Running xmodmap -pke gives me (among other lines):

    keycode 22 = BackSpace BackSpace BackSpace BackSpace BackSpace BackSpace
    

    I change this line to

    keycode 22 = BackSpace Delete Delete Delete Delete Delete
    

    and save it in the file ~/.Xmodmap and run xmodmap ~/.Xmodmap. Apparently, this worked in part. When I run xev and press Shift+Backspace I get:

    KeyPress event, serial 37, synthetic NO, window 0x1200001,
        root 0x300, subw 0x0, time 133664788, (484,630), root:(584,799),
        state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
        XLookupString gives 0 bytes: 
        XmbLookupString gives 0 bytes: 
        XFilterEvent returns: False
    
    KeyPress event, serial 37, synthetic NO, window 0x1200001,
        root 0x300, subw 0x0, time 133665052, (484,630), root:(584,799),
        state 0x1, keycode 22 (keysym 0xffff, Delete), same_screen YES,
        XKeysymToKeycode returns keycode: 119
        XLookupString gives 1 bytes: (7f) ""
        XmbLookupString gives 1 bytes: (7f) ""
        XFilterEvent returns: False
    
    KeyRelease event, serial 37, synthetic NO, window 0x1200001,
        root 0x300, subw 0x0, time 133665116, (484,630), root:(584,799),
        state 0x1, keycode 22 (keysym 0xffff, Delete), same_screen YES,
        XKeysymToKeycode returns keycode: 119
        XLookupString gives 1 bytes: (7f) ""
        XFilterEvent returns: False
    
    KeyRelease event, serial 37, synthetic NO, window 0x1200001,
        root 0x300, subw 0x0, time 133665444, (484,630), root:(584,799),
        state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
        XLookupString gives 0 bytes: 
        XFilterEvent returns: False
    

    With other modifier keys (LeftAlt, RightAlt, LeftCtrl) I still get BackSpace.

    But xev seems to be the only application that recognizes Delete. In Wayland applications I get only Backspace, no matter what modifier key (Shift, LeftAlt or RightAlt, LeftCtrl) I press. In Firefox (an X application) there is a change. Now, Shift+Backspace does nothing. I suppose this is because Shift+Delete does nothing as well. The KeyPress event of Shift_L seems to block Delete from being obeyed by applications, which is unfortunate when Shift is part of a key combination that maps to Delete. How can I undo this block of Delete? How can I make the key mapping work in Wayland and X applications?

    E 1 Reply Last reply
    1
    14
    • C [email protected]

      I want to change the key mapping of Shift+Backspace to Delete.

      Running xmodmap -pke gives me (among other lines):

      keycode 22 = BackSpace BackSpace BackSpace BackSpace BackSpace BackSpace
      

      I change this line to

      keycode 22 = BackSpace Delete Delete Delete Delete Delete
      

      and save it in the file ~/.Xmodmap and run xmodmap ~/.Xmodmap. Apparently, this worked in part. When I run xev and press Shift+Backspace I get:

      KeyPress event, serial 37, synthetic NO, window 0x1200001,
          root 0x300, subw 0x0, time 133664788, (484,630), root:(584,799),
          state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
          XLookupString gives 0 bytes: 
          XmbLookupString gives 0 bytes: 
          XFilterEvent returns: False
      
      KeyPress event, serial 37, synthetic NO, window 0x1200001,
          root 0x300, subw 0x0, time 133665052, (484,630), root:(584,799),
          state 0x1, keycode 22 (keysym 0xffff, Delete), same_screen YES,
          XKeysymToKeycode returns keycode: 119
          XLookupString gives 1 bytes: (7f) ""
          XmbLookupString gives 1 bytes: (7f) ""
          XFilterEvent returns: False
      
      KeyRelease event, serial 37, synthetic NO, window 0x1200001,
          root 0x300, subw 0x0, time 133665116, (484,630), root:(584,799),
          state 0x1, keycode 22 (keysym 0xffff, Delete), same_screen YES,
          XKeysymToKeycode returns keycode: 119
          XLookupString gives 1 bytes: (7f) ""
          XFilterEvent returns: False
      
      KeyRelease event, serial 37, synthetic NO, window 0x1200001,
          root 0x300, subw 0x0, time 133665444, (484,630), root:(584,799),
          state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
          XLookupString gives 0 bytes: 
          XFilterEvent returns: False
      

      With other modifier keys (LeftAlt, RightAlt, LeftCtrl) I still get BackSpace.

      But xev seems to be the only application that recognizes Delete. In Wayland applications I get only Backspace, no matter what modifier key (Shift, LeftAlt or RightAlt, LeftCtrl) I press. In Firefox (an X application) there is a change. Now, Shift+Backspace does nothing. I suppose this is because Shift+Delete does nothing as well. The KeyPress event of Shift_L seems to block Delete from being obeyed by applications, which is unfortunate when Shift is part of a key combination that maps to Delete. How can I undo this block of Delete? How can I make the key mapping work in Wayland and X applications?

      E This user is from outside of this forum
      E This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      xmodmap was meant to work with x11 so it shouldn't be a surprise that it doesn't work very well w wayland.

      instead, you'll want to use a combination of libinput and evdev along w gnome/kde tools or input-remapper/wlr-inputremapper if you're not using either.

      1 Reply Last reply
      3
      • System shared this topic
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups