Create META SUPER HYPER in Windows

User avatar
Minskleip

13 Aug 2011, 00:12

With a programmable keyboard I can finally replace all the useless keys with something better, like META, SUPER and HYPER. Then I could use these new modifier keys in Emacs. However, I haven't found any way of creating these modifiers in Windows (it's easy in Linux), but I can remap then to something else like F13 etc. Finally, I can't figure out how to map F13 to HYPER in Emacs! It's easy to map the 'Windows key' to HYPER, but the only way I've found is to map F13 like a regular key, but this doesn't allow for complex keychords or holding it down for more than a few seconds.

Any Emacs gurus here who know how to do this?

User avatar
webwit
Wild Duck

13 Aug 2011, 00:26

IANAEG, but this seems to list the method and also the inherent problems of low level Windows bindings:
http://xahlee.org/emacs/emacs_hyper_super_keys.html

User avatar
Minskleip

13 Aug 2011, 00:46

That's the best information I've found on the subject, but it only let Emacs map the windows and app keys, not arbitrary keys. I want windows, app, meta, super and hyper :D

Edit: maybe it could be possible to make some kind of Autohotkey concoction, where for instance F13 is sent as RWIN if the active window is Emacs..

User avatar
Minskleip

15 Aug 2011, 22:26

I think I'll end up doing something like this (in a check if active window is emacs clause):

Code: Select all

F22 & F23::
Input, OutputVar, L1
if OutputVar = h
	SendInput !{F22}^hs
	return
return
When pressing F22 and F23, Ahk waits for the next input, and it that is `h', sends

Code: Select all

M-<f22> C-h s
to Emacs, which interprets it as a regular key chord. This way I can make custom mega long bindings which doesn't interfere with Emacs' defaults, and trim them with Ahk.

Still not as cool as having the real deal though...

Reason for dong this: I want to use Emacs for Lisp programming, but I don't want to learn Emacs 8-)

User avatar
Minskleip

26 Aug 2011, 19:29

Found a third option here[1], and using the windows keys for super and hyper started working :?

By programming three keys on be F21, F22 and F23, it's possible create hotkeys with Autohotkey which sends input/macros to Emacs causing it to set either super, hyper or alt (or meta, so you can mix and match if you want to use app for meta or not) "Emacs modifier bits"! Unfortunately you can only set one bit this way, but because app can be set to meta, one can use such key chords as "C-M-A-H-S-key"[2][3] lol

Autohotkey:
F21::
SendInput ^x@m
return

F22::
SendInput ^x@s
return

F23::
SendInput ^x@h
return
#IfWinActive

It would probably be better to use the windows keys in practice though, because they being real modifiers can be hold down for issuing multiple hyper-bindings without emacs going off.

This is how you can stop win+r from starting the run dialogue while in emacs:
#IfWinActive ahk_class Emacs
LWin & r::
Send {LWin Down}{F13}{LWin Up}
return
#IfWinActive

Then bind H-<f13> (assuming left windows is hyper) to some command.

[1]: http://www.gnu.org/software/emacs/manua ... -Keys.html
[2]: I tried with C-M-x where M was made by a f21 programmed key.
[3]: With this method you can just press and release the special key; holding it down makes the hotkey repeat itself (since the keyboard key is really just a key and not a modifier). Maybe I should program a key to turn off auto repeat ;)


Edit:
Emacs can use scroll lock as a (locking) modifier. It works great, and one can use Autohotkey to simulate two key presses if you don't want it to lock:

ScrollLock::
Send {Blind}{ScrollLock}
return

ScrollLock Up::
Send {Blind}{ScrollLock}
return

With this it's possible to have hyper, super and windows! Getting close to 98% success. 99% would be to recompile Emacs to use arbitrary keys as modifiers, and 100% would be to actually have hyper and super etc without hacks!

Konrad

29 Aug 2011, 07:59

I suppose no modern manufacturer offers anything derived from the old Space Cadet keyboards?

User avatar
Minskleip

29 Aug 2011, 09:41

There's no scan codes, so you'd have to write your own driver and rewrite all software to be able to use the new keys :?

The real solution to my problem, however, is to recompile Emacs so that w32-lwindow-modifier et. al. refer to other keys than LGUI et. al. This really should be configurable in Emacs already, at least on Windows where we don't have xmodmap to create hyper and super.

Konrad

30 Aug 2011, 02:25

Hmm, I wonder if it's worth getting some sort of Sun keyboard. I notice that clones and refurbs are still available, although quality seems dubious.

User avatar
Minskleip

17 Sep 2011, 20:01

A better Autohotkey hack for making scroll lock not togglable which doesn't make it go retard and mess up Teensy:

ScrollLock::
SetScrollLockState, On
return

ScrollLock Up::
SetScrollLockState, Off
return

Post Reply

Return to “Keyboards”