Categories
Linux

Magicforce Smart 68 key mechanical keyboard – Linux mappings

Given I’m working from home I thought I’d set up a more permanent workspace instead of using a laptop. Doing away with the laptop keyboard I realised that we didn’t have a free standalone keyboard in the house so I went shopping on eBay. After a bit of background reading I decided I fancied trying a ‘mechanical’ keyboard. A distant memory is enjoying using the original IBM PC keyboards (I used the Model F) with their long travel and clicky keys.

I didn’t want a full size keyboard, I have no use for the number pad, its where I want my mouse to be. I really wanted white to match the decor, and I specifically wanted the cursor keys a little separate from the shift / enter keys. There were a few on eBay under my £30 budget but mainly black, or in China and in this case I couldn’t wait that long. So I’ve ended up with a “Magicforce | smart 68 Keys Mini Mechanical Keyboard” as it says on the back, a blue switch model, at £29 delivered. This was 2nd hand but I could see from the pictures that this keyboard was in pretty good condition anyway and these are really easy to clean because all the key caps are designed to come off, to be swapped even.
Magicforce Smart 68 key Mechanical Keyboard
After a few days of using it, its a great keyboard, though for the UK it could really do with an extra key. Now I’ve mapped the keys to my liking I can live with this though. I saw that there were some 69 key versions of this keyboard so perhaps this has been addressed already.

Anyway, if you have a keyboard and its not quite working for you, this is how I remapped mine:

I selected a Generic 104 key PC keyboard, with English (UK) layout, though I understand that perhaps selecting a US keyboard maps most keys properly, the UK layout does at least change the Shift-3 to a pound sign.

To backup the existing keyboard mappings:
xmodmap -pke >~/.Xmodmap-original

Use xev to see what key is mapped when a particular key is pressed:
xev -event keyboard -name HoverOverMe -geometry 300x20

If you cannot get the relevant key from xev (like if its not been mapped yet) you can get a list of all the keys / keycodes currently set up, though some of these are wrong e.g. three is 3.:
sudo dumpkeys -l >/tmp/keycodes

Use xmodmap to replace change a keycode to something else.
xmodmap -e "<keycode> = <keysym> <keysym> <keysym> <keysym> <keysym> <keysym>"
The sequence of these mappings is: Key, Shift+Key, mode_switch+Key, mode_switch+Shift+Key, AltGr+Key, AltGr+Shift+Key.
AltGr means the right alt, on this keyboard at least. To skip a column use NoSymbol as the keysym.

On this Magicforce 68 key keyboard using Mint 19.3 xfce4 I’ve done the following:

xmodmap -e "keycode 11 = 2 quotedbl NoSymbol NoSymbol twosuperior"
xmodmap -e "keycode 12 = 3 sterling NoSymbol NoSymbol numbersign"
xmodmap -e "keycode 48 = apostrophe at NoSymbol NoSymbol grave"
xmodmap -e "keycode 49 = NoSymbol asciitilde"
xmodmap -e "keycode 51 = backslash bar NoSymbol NoSymbol numbersign"
xmodmap -e "keycode 66 = NoSymbol Caps_Lock"

Yes, I rarely use CAPS (what is the point of it – a conversation for another day) and I tend only press it by mistake, so this makes CAPS only work with SHIFT-CAPS. Shame to lose all that keyboard real-estate but mapping another key to it doesn’t make sense to me. Shame though because on this keyboard there is a cool green backlight under the key.

To save the layout use the command:
xmodmap -pke >~/.Xmodmap

Make these mappings go live at startup (there are lots of ways to do this, this seems the easiest, you could make it a systemd service or something though).

cat > ~/.config/autostart/keyboard-mappings-MF68.desktop <<EOC
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=Keyboard mappings for Magicforce 68
Comment=Keyboard mappings for Magicforce 68 by Mat Sims
Exec=/usr/bin/xmodmap ~/.Xmodmap
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false
EOC

You can run xmodmap ~/.Xmodmap anytime to set them. I find that on Mint 19.3 xfce4, after running xmodmap, xfsettingsd starts using too much CPU for an extended period. Give it a minute or so and it does normally calm down but if not, kill it and it should restart and behave.

If you find that you have messed up the keyboard you can get back the original settings with:
xmodmap ~/.Xmodmap-original