In https://coq.vercel.app for example (but also my own stuff) when I press <
, it inserts a \
and pops up a menu for me to chose among special chars. Any idea why? Is this a local setup? is it codemirror? Is there an option I can switch somewhere? (FYI I deactivated company-coq just in case, but the problem persists)
(CC @Enrico Tassi, @Emilio Jesús Gallego Arias, @Shachar Itzhaky)
excerpt from tex-input-hint.js
:
List of open issues: [...]
- Review if the way we capture the '\' keypress comforms to CM
coding standards.
I'd say probably not? :laughter_tears:
Huh, this does not happen to me. Also super weird! I have no idea why this should happen. What browser?
google-chrome, french keyboard, french system layout
Can you try to comment out this in tex-input-hint.js
? To see if that's what's causing it.
cm.addKeyMap({"\\": function(cm)
{
cm.replaceSelection("\\");
cm.execCommand("autocomplete");
}});
If I switch to english layout, then both <
and \
become special (while in the french layout only <
is).
Shachar Itzhaky said:
Can you try to comment out this in
tex-input-hint.js
? To see if that's what's causing it. [...]
Already tried, does not work.
Wait no, it does work
Cyril Cohen said:
If I switch to english layout, then both
<
and\
become special (while in the french layout only\
is).
Oh wow the plot thickens
Cyril Cohen said:
Wait no, it does work
I'll go with it for now...
Just to make sure, did you try the CodeMirror website https://codemirror.net (which contains a small editor widget as a demo)? When you type '<' there, it works correctly..?
Shachar Itzhaky said:
Just to make sure, did you try the CodeMirror website https://codemirror.net (which contains a small editor widget as a demo)? When you type '<' there, it works correctly..?
Yes, it works correctly, and if I uncomment cm.addKeyMap({"\\": function(cm)
it also works correctly
(although I lose the use of special chars)
do you have an AZERTY keyboard?
I've found that the <
in the AZERTY layout is located exactly where the \
is in certain layouts (British?), e.g. this SE question:
https://askubuntu.com/questions/444810/editing-keyboard-layout
Shachar Itzhaky said:
do you have an AZERTY keyboard?
Yes I do
Perhaps try an English (US)
as your English layout? This is one of the most obscure bugs!
@Emilio Jesús Gallego Arias @Bas Spitters What do your keyboards look like?
American and Danish :-)
Spanish / UK
Hah :D
Who's in for a fun experiment? Run this in your JS console, then switch back to the page and type \
:
document.addEventListener('keydown', console.log)
Let me know what key
, code
, and keyCode
you get :laughing:
I'm getting: key: '\\', code: 'Backslash', keyCode: 220
Oh and repeat for <
. Here's what mine gives: key: '<', code: 'Comma', keyCode: 188
KeyboardEvent {isTrusted: true, key: '\\', code: 'Backquote', location: 0, ctrlKey: false, …
Keycode 220
for <
code: "IntlBackslash" keycode "220"
ha!
same keycode!
what's going on!
This is with French Hardware, but spanish keyboard in Linux
I'll try asap
When I press <
key: '\', code: 'Backslash', keyCode: 220
Yeah the bug is confirmed, for some reason both keys have the same keycode
I guess a possible workaround would be to read which character has actually been inserted...
or just code, but indeed, that needs fixing
"or just code" ?
Oh and if I type \
on my french keyboard it is AltGr+8:
key: "8", keyCode: 56, code: "Digit8"
:laughter_tears:
key_backslash.png
key_lessthan.png
on keypress, e.key
looks fine though...
document.addEventListener('keypress', e => console.log("keypress: " + e.key))
gives me the right results
perhaps... we are using CodeMirror's keymap, which hides the actual event binding, but perhaps there's a way to get the actual event, or hook into keypress instead of keydown, manually.
Last updated: Jun 01 2023 at 11:01 UTC