Linux: How to Swap Control & Alt Keys

, , …,

This page shows you how to swap the CtrlAlt key for Linux.

On some Linux, you can simply go to the system control panel, and there's a keyboard settings app. That may or may not let you swap the keys.

Here's how you can do it system-wide under X11.

! -*- coding: utf-8 -*-
! 2013-02-04 swap Alt and Ctrl http://xahlee.info/

!  xmodmap -pke | egrep '(Control|Super|Alt|Menu)'
! keycode  37 = Control_L NoSymbol Control_L
! keycode  64 = Alt_L Meta_L Alt_L Meta_L
! keycode 105 = Control_R NoSymbol Control_R
! keycode 108 = Alt_R Meta_R Alt_R Meta_R
! keycode 133 = Super_L NoSymbol Super_L
! keycode 134 = Super_R NoSymbol Super_R
! keycode 135 = Menu NoSymbol Menu
! keycode 147 = XF86MenuKB NoSymbol XF86MenuKB
! keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
! keycode 206 = NoSymbol Super_L NoSymbol Super_L

clear control
clear mod1
keycode 37 = Alt_L Meta_L
keycode 105 = Alt_R Meta_R
keycode 64 = Control_L
keycode 108 = Control_R
add control = Control_L Control_R
add mod1 = Alt_L Meta_L

Save the above into a file at ~/.Xmodmap, then logout and back in.

back to Linux: xmodmap Tutorial ⌨

blog comments powered by Disqus