Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<C-[> no longer works in textareas #175

Open
arxanas opened this issue Aug 29, 2016 · 3 comments
Open

<C-[> no longer works in textareas #175

arxanas opened this issue Aug 29, 2016 · 3 comments

Comments

@arxanas
Copy link

arxanas commented Aug 29, 2016

I principally use <C-[> to exit from insert mode because <ESC> is not very ergonomic. (I believe this keybinding was carried over from Vim.) As of #168, typing <C-[> no longer works. Adding this entry does not work either, whether in my .pentadactylrc or when adding the mapping directly in the browser:

imap <C-[> <ESC>

<ESC> still works, but I don't like <ESC>.

Expected behavior: typing <C-[> while typing in a text field will remove the focus from that text field, and go back to normal mode.

Actual behavior: <C-[> has no effect in a text field.

@betaveros
Copy link

betaveros commented Oct 27, 2016

I also recently found <C-[> no longer doing anything in pass-through mode and I also somewhat need it (reveal.js gobbles up Escape...)

I'm on OS X 10.10.5, and digging into it in Firefox Developer Edition, it appears that the <C-[> event's charCode now 0 and so this condition is no longer triggered:
https://github.com/5digits/dactyl/blob/c1f353789886cc3ad711269fd62face65b2f79c1/common/modules/dom.jsm#L1381

I don't know the right fix or how the KeyboardEvent's API is changing, but the event looks like it has code: "BracketLeft" and key: "[" attributes that one might test against.

@betaveros
Copy link

A questionable patch that seems to work:

diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm
index efcc56b..45f1984 100644
--- a/common/modules/dom.jsm
+++ b/common/modules/dom.jsm
@@ -1341,7 +1341,16 @@ var DOM = Class("DOM", {
                 modifier += "M-";

             if (/^key/.test(event.type)) {
-                let charCode = event.type == "keyup" ? 0 : event.charCode; // Why? --Kris
+                let charCode = event.charCode;
+                if (event.key && "[\\]^_".indexOf(event.key) >= 0) {
+                    // The [Ctrl-Bug] documented below stopped working recently
+                    // (2016) and charCode is just 0 for those ctrl-keys for
+                    // some reason. Restore a good charCode to fall-through to
+                    // the third case.
+                    charCode = event.key.charCodeAt(0);
+                }
                 if (charCode == 0) {
                     if (event.keyCode in this.code_key) {
                         key = this.code_key[event.keyCode];

The conditional let charCode = event.type == "keyup" ? 0 : event.charCode; was introduced in the commit a1dbd3f ; I couldn't tell if it was still relevant so I just deleted it...

@ernestorocha
Copy link

ernestorocha commented Nov 14, 2016

It would be awesome to have this again! Anyone tried that solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants