1

Just got new laptop -- Acer Swift Lite 14 running Windows Home 11. The machine comes with Copilot key in the place of right ctrl.

enter image description here

With suggestion on internet I can use MS PowerToys to remap the shortcut from Copilot key (which PowerToys detected as Win (Left) + Shift (Left) + F23) to Ctrl (Right)

The remapping works fine in any app except some cases in Emacs.

Simple case like C-a (move-beginning-of-line) works fine.

But when there is any following non Ctrl-sequence like C-x b, Emacs will report error like "C-x <lwindow> is undefined"

Looks like when I release the Copilot key (before press next key), for some reason, Emacs detects a <lwindow> key press. No idea why.

I have to add shortcut with <lwindow> like this to workaround this.

(global-set-key (kbd "C-x <lwindow> b") 'switch-to-buffer) 

Anybody, have better suggestion to properly fix this ?

Update

I use Lazarus to print out what keycode produced when Copilot is pressed after PowerToys shortcut mapping. Below is the result

  1. <lwindow> key down

  2. <shift> key down

  3. "char 255" key down

  4. "char 255" key up

  5. <shift> key up

  6. <lwindow> key up

  7. <ctrl> key down

  8. <ctrl> key up

  9. <lwindow> key down

  10. "char 255" key down

  11. "char 255" key up

  12. <lwindow> key up

PowerToys did produce <lwindow> key sequence (1 - 6) before <ctrl> (7 - 8) And also after (9 - 12)

As far as I know Emacs has code in w32-win.el to ignore <lwindow>, because generally <lwindow> will make active Window switch to other and Emacs will never receive <lwindow> key up event. But this case it is not.

8
  • Note that the problem does not exist on Emacs running in WSL2. Commented Mar 12 at 11:49
  • Oh sorry I forgot to mention that I use Windows 11 Home Commented Mar 12 at 12:42
  • What is copilot key? Commented Mar 12 at 12:42
  • 2
    Ah, I see. Another Microsoft’s wrongdoing. Commented Mar 12 at 12:45
  • 1
    I'm working on a script to automatically find all "C-x ..." keymaps and add more keymaps with "C-x <lwindow> ..." to solve my problem. Will update this question for other people having same problem as mine. Commented Mar 17 at 6:04

1 Answer 1

2

After remap Copilot key to Ctrl with MS PowerToys, it turns out PowerToys emit <lwindow> key code along with the <ctrl> key that I want. Apps other than Emacs don't seem to have problem with that. But for Emacs, I've found that we need to configure it to ignore this <lwindow> code

To solve this problem, simply add this line to your config is enough :)

(define-key special-event-map (kbd "<lwindow>") 'ignore) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.