An Autohotkey remapping script I'm using uses the function keys F13-F24 to keep track of layers. This means that {F13 Down}, for example, may get sent as a virtual key code.
This works fine for most applications. However, Emacs recognizes the function keys and does not pass them through (even though they don't exist on my keyboard and I can't activate them external to Autohotkey). This is causing unwanted behavior when I switch layers.
I can make the "key undefined" messages go away by using
(global-set-key [f13] 'ignore)
(global-set-key [f14] 'ignore)
...
However, Emacs still registers the keys, and they will stop sequences for commands. For example, in Spacemacs one switches windows using Spc 0-9
. To access the numbers, I press a key that sends {F13 down}, then press a letter key. Rather than Spacemacs interpreting this as Spc #
, a message prints saying that Spc <f13>
is undefined. Even though they are nil, Emacs still "recognizes" them.
What I would like to do would be to have Emacs completely ignore the F13-F24 keys. That is, if Emacs receives a keycode corresponding to some key from F13-F24, it doesn't even register it, but ignores it as if it had not been pressed.
I tried using
(define-key input-decode-map (kbd "<f13>") nil)
(define-key input-decode-map (kbd "<f14>") nil)
...
in my config file, but the keys still register. According to my understanding of Translation Keymaps, I thought this would work. I'm at a bit of a loss now as to how I might go about disabling these keys.
Help?
Edit: I have solved the issue on the Autohotkey end of things. Instead of using F13-F24 for keeping track of layers, I'm using unassigned virtual key codes. (See this thread). It's a bit harder to maintain, but there is no interference with Emacs.
I've gone ahead and accepted @Gilles' answer since it mostly worked on the Emacs side of things. There were intermittent problems with auxiliary modes/maps getting activated that I was never able to pinpoint. I seemed to only have problems switching windows with Spc <f13> <letter>
= Spc #
when I was going from window to window with no keypresses in between. If I pressed Esc every time I arrived at a window before using Spc #
to go to a different one, everything worked fine.
I'm pretty new to programming in general and Emacs in particular, so someone more knowledgeable might be able to actually create full pass through on the Emacs side of things. Here's some links that looked like they would be useful if I knew what I was doing:
global-set-key
version, try setting them tonil
.ignore
is a function and will swallow the keybindings.