Ubuntu – Map a key to another key as keyboard damaged

keyboardshortcut-keys

My @ or 2 key is not working. I want to set it like, if user press Alt + a or something the 2 should be inserted to the active window. I have achieved this in windows using Auto It. In ubuntu i saw some solutions but couldn't do it. Any help would be appreciated. Or else i will be forced to move back to windows 🙁

Best Answer

First install xbindkeys and xte by running:

sudo apt-get install xbindkeys xautomation  
  1. Create the xbindkeys configuration file: xbindkeys --defaults > $HOME/.xbindkeysrc

  2. Next we need to edit the file. Run gedit .xbindkeysrc

  3. Add this to the bottom of the file:

    "xte 'key 2'"
    m:0x18 + c:38  
    Alt+Mod2 + a  
    
  4. Save the file.

  5. Open "Startup Applications" from the dash, and click "Add".

  6. Put /usr/bin/xbindkeys and click "Add".

  7. Restart the computer.

Your 2 key should now be bound to Alt + a.