#+TITLE: Keyboard layout: GB layout with dead keys on Linux, macOS, Windows I'm using a UK keyboard layout with dead keys to access accents. The inspiration is [[https://www.zolid.com/uk-intl-kb/index.htm][James Campbell's UK International keyboard]], but I deviated a little bit, eg.: =AltGr+o= becomes œ, =AltGr+a= is æ, this makes typing « mon cœur » and "UNIX© dæmon" easier. In [[https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/blob/master/symbols/gb?ref_type=heads][xkeyboard-config's default layouts]], the "English (UK)" layout puts the grave on the =#= hash sign and the circumflex on the =@= key, which is a choice I don't like. The "English (UK, intl., with dead keys)" layout puts the dead keys on more sensible positions eg. grave on the =`= key, but the dead keys are the primary keys, without an =AltGr=, which I find annoying. Hence making my own layout, this [[file:../images/uk-FR-accents.png][is the final result]]. * Linux with X11 Install [[file:../stuff/keyboards/xkb/uk-intl.xkb][uk-intl.xkb]] somewhere in =$HOME=. Arrange to run =xkbcomp uk-intl.xkb $DISPLAY= on session startup. This includes a remapping of Caps Lock to be a second control. * Linux with Wayland At some point, this stopped working when I moved to a desktop that uses Wayland only, without X11. It appears that changes to input handling means =xkbcomp= can't change the display's server layout, or something. Peter Hutterer wrote a series of posts: [[https://who-t.blogspot.com/2020/09/user-specific-xkb-configuration-putting.html?m=1][User-specific XKB configuration]], describing how to allow local user configuration to augment the system's built-in layouts in the new world of Wayland. =libxkbcommon='s documentation has [[https://xkbcommon.org/doc/current/user-configuration.html#md_doc_2user-configuration][much the same information]]. In essence, we're defining a new =gb= variant that only has the changes from the base layout. Extract [[../stuff/keyboards/xkb.tar.gz][xkb.tar.gz]] in =$XDG_CONFIG_HOME= (so that the variant file ends up as =~/.config/xkb/symbols/gb=). Log out / back in, then select the new variant: under GNOME, go in the "Settings" tools, "Keyboard" page, in "Input Sources" the little "+", "Add an Input Source" for "English (United Kingdom)", and find "English (French accents on dead keys)". While we're at it, =C-.= starts [[https://fedoraproject.org/wiki/Changes//IBus_Emoji_Typing][IBus emoji typing]], to disable that: : gsettings set org.freedesktop.ibus.panel.emoji hotkey "[]" Under KDE, to activate the new keyboard, go to "System settings", "Input & Output", "Keyboard", "Layout": "Add...". * macOS Download and install [[file:../stuff/keyboards/UK Intl mk7.bundle.tar.gz][UK Intl mk7]]. This can be edited with [[https://formulae.brew.sh/cask/ukelele][Ukulele]]. I started from the GB keyboard layout and added a small number of dead keys. As a result there may be other key combos that are different from Linux' layout above, for characters I don't use (or not often). The mark "mk7" is because any modification requires a new name, and that's how many attempts it took me to be happy. I remember issues with the =`= key being confused with the =\= key, but I don't remember if that was fixed by changing the layout definition or changing an option in macOS' menus. See also [[https://support.apple.com/en-gb/guide/mac-help/mchlp1011/mac][Change the behavior of the modifier keys]] to make Caps Lock another Control. I also have the following to avoid unfortunate keyboard shortcuts: ** iTerm2 iTerm2 has a number of annoying shortcuts that conflict with standard key combos from readline eg. =C-w= to close a tab. The following will disable those. Each option to the left of the === sign is an entry from a menu, to the right is a unicode char. U+200B is "zero-width space", something we can't hit by accident. #+BEGIN_SRC sh defaults write com.googlecode.iterm2 NSUserKeyEquivalents '{ "Split Horizontally with Current Profile"="\U200B"; "Split Vertically with Current Profile"="\U200B"; "Split Horizontally..."="\U200B"; "Split Vertically..."="\U200B"; "Close"="\U200B"; "Close Terminal Window"="\U200B"; "Close All Panes in Tab"="\U200B"; "Minimize"="\U200B"; "Reset"="\U200B"; }' #+END_SRC ** Outlook The default =Cmd+V= results in messed up fonts. Ideally it'd be replaced with a "paste" command that keeps text only, but I couldn't find this in the menus, so "match style" is the least worst option. #+BEGIN_SRC sh defaults write com.microsoft.Outlook NSUserKeyEquivalents '{ "Paste"="\U200B"; "Paste and Match Style"="@v"; }' #+END_SRC The =@= prefix is Cmd, =^= would be Control, =~= for Option, =$= for Shift. * Windows 10 Get [[../stuff/keyboards/ukint20a-FP.zip][ukint20s-FP.zip]], which contains a binary file (a =.msi=) that requires administrative rights to install then a reboot. This works on Windows 10 at least, and worked on the last version of Windows that =$WORK= forced me to use before that. The source file is a =.klc= text file, which can be edited with [[https://www.microsoft.com/en-gb/download/details.aspx?id=102134][Microsoft Keyboard Layout Creator]] and then compiled the =.msi= which can be installed. MKLC requires .Net Framework, which needs [[https://learn.microsoft.com/en-gb/dotnet/framework/install/dotnet-35-windows][twiddling in the settings]] to install and make available. In order to remap Caps Lock to Ctrl, use [[https://learn.microsoft.com/en-us/sysinternals/downloads/ctrl2cap][ctrl2cap]] (this is a sysinternal tool by Microsoft; it requires admin access for installation, and a reboot after).