Can I change the movement keys in NetHack?
I recently downloaded NetHack, and have begun to play on my laptop. However, I find the directional key bindings rather cumbersome. I do not have a Number Pad, and would rather not use the NumLock function on my laptop's keyboard. So, I'm currently left to deal with the default non-numerical bindings for movement. These are very counter-intuitive.
The help file displays them as this:
y k u
\|/
h-.-l
/|\
b j n
When, in reality, they're laid out more like this:
YU
HJKL.
BN
Is there any way to change this key binding to be less confusing - perhaps even using the actual directional keypad?
Solution 1:
As far as I know, there's no way to remap the keys outside of a recompiling from source, or a crazy hack like using AutoHotKey to map entirely different keys on the keyboard to hjkl/yubn. Obviously that has side-effects though.
So you have a couple of options:
- You may not have an actual numpad, but most laptops have a mode that can "convert" part of the keyboard into a numpad, by holding down the "Fn" key, or using a "Fn Lock" key to toggle it on/off.
- Get used to hjkl/yubn, and be glad that if you ever decide to learn how to use vim in the future, you'll already have moving around with hjkl solidly ingrained into your muscle memory.
Solution 2:
You don't say which version of Nethack you're using, but I think most of the GUI clients should support directional keys. The Windows port definitely does.
Solution 3:
You cannot change the movement keys because they are unfortunately hardcoded in the source code. Not everyone is using a layout close to qwerty so it is very unfortunate.
However you can recompile the source to change the keys. I have created a patch that change the keys:
https://gist.github.com/kototama/19c514e69c89b464067507099d5b64ec
You can adapt it to specify the keys you want, in my case it was done to be convenient with the Colemak Mod DH layout.
Compilation instructions of NetHack are in the repo: https://github.com/NetHack/NetHack. Recompiling NetHack is not as complex as it seems. Good luck!
I hope this post helps people searching for a solution.