1

I use super modifier because it is transparent to any keymap (for example there is no need for C-c C-j or C-c C-x o in term terminal mode, any s-... command just works). Under X I use xmodmap.

Under Windows 10 it is hard to use Win key with letters and arrows key because this key binding is native to Windows (only Win+F2 - Win+F12, Win+Ins, Win+Del, Win+PgUp, Win+PgDown passed back to Emacs) and:

(setq w32-pass-lwindow-to-system nil
      w32-pass-rwindow-to-system nil
      w32-pass-apps-to-system nil
      w32-lwindow-modifier 'super ; Left Windows key
      w32-rwindow-modifier 'super ; Right Windows key
      w32-apps-modifier 'hyper) ; Menu key

doesn't help for LWin in Cygwin emacs-w32.

I wander if it's possible to use CapsLock as super modifier in Windows native and Cygwin emacs-w32...

My laptop has only LWin and the only useless key is CapsLock... There is num-pad but it is far from my hands usual position...

  • 1
    "How to bind caps lock" has come up a lot in the past: see the following for option emacs and caps lock. – Dan Jan 27 '17 at 15:59
2

I feel your pain. Coming up with a decent hyper/super key binding which will work across all my keyboards is an ongoing search, especially given the widely varying laptop keyboard layouts.

I dislike using the Windows key because it is actually useful when I am in Windows, and Windows steals an ever-increasing set of Win- keypresses at a low level which Emacs cannot intercept.

The approach I am taking is to turn CapsLock into Control, then turn the left Control key into Apps (because not all my keyboards have Apps). Then I do the w32-apps-modifier thing to turn it into a hyper key as you are doing in your question. This works well for emacs-w32, you get a genuine non-sticky modifier. In the terminal, it functions as a sticky modifier bound to <print> See my question at Making terminal Emacs treat APPS (aka MENU) key as super modifier for more details.

I achieved the key remapping using a €15 tool called kbedit http://www.kbdedit.com/. You could probably achieve something similar using AutoHotkey but I like kbdedit because it actually installs a new keyboard layout in Windows rather than intercepting messages. Just feels much cleaner.

1

There is a solution for my problem, that possible without any external dependencies!!

According to https://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-Keyboard.html native Emacs can:

w32-apps-modifier
  Variable: Modifier to use for the "Apps" key.
w32-lwindow-modifier
  Variable: Modifier to use for the left "Windows" key.
w32-rwindow-modifier
  Variable: Modifier to use for the right "Windows" key.
w32-scroll-lock-modifier
  Variable: Modifier to use for the Scroll Lock ON state.

Withing article Keyboard and mouse class drivers there is possibility to adjust keyboard layout (for all user) playing with keycodes.

There is Keyboard Scan Code Specification for PS/2 compatible keyboards.

Firstly I try to use w32-scroll-lock-modifier:

(setq w32-scroll-lock-modifier 'super)

in order to keep other modifiers without changes:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
; CapsLock => ScrollLock
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,46,00,3a,00,00,00,00,00

but Scroll Lock keeps state, so releasing after first pressing keeps scroll on as if super key is still pressed and not released.

It can be emacs-w32 v24 Cygwin bug. But I move further...

Now I succeeded with:

(when (eq window-system 'w32)
  (setq w32-apps-modifier 'super))

But my hands trained to work with LWin, and not with Caps Lock. So I made 2 swaps and with:

; CapsLock (3a,00) => LWin (5b,e0); LWin (5b,e0) => Apps (5d,e0)
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,5b,e0,3a,00,5d,e0,5b,e0,00,00,00,00

LWin key is actually Apps key and LWin moved to Caps Lock.

Now my Windows keyboard workflow doesn't differ from X workflow.

Of course I disable layout switching to preserve Ctrl / Alt / Shift solely to Emacs with:

[HKEY_CURRENT_USER\Keyboard Layout\Toggle]
; The value 1 specifies that LEFT ALT+SHIFT switches locales.
; The value 2 specifies CTRL+SHIFT.
; 3 disables the key sequence altogether.
; I decide use AutoHotkey to switch locales.
;
; These customisations have affect at least after logout/login.
"Hotkey"="3"
"Language Hotkey"="3"
"Layout Hotkey"="3"

With above settings I switch layout with Caps Lock + Space ))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.