monome / maiden

web based editor and repl for norns
GNU General Public License v3.0
47 stars 34 forks source link

`ctrl+p` keybinding not working in some browsers #71

Closed pq closed 5 years ago

pq commented 6 years ago

reported by @artfwo, ctrl+p does not work in:

i've also seen it not taking in:

pq commented 6 years ago

@artfwo: when you have a moment, could you tell me what you see for "which" and "keyCode" when you type p in here?

https://css-tricks.com/snippets/javascript/javascript-keycodes/#article-header-id-0

artfwo commented 6 years ago
     which: 80
  keyCode: 80
    shiftKey: false
     altKey: false
    ctrlKey: false
   metaKey: false 
pq commented 6 years ago

i saw this yesterday on chrome (on a chromebook) so the os (and keyboard) may not be related. more to investigate...

x2mirko commented 6 years ago

I have the same issue on chrome / win10

pq commented 6 years ago

ah, thanks @x2mirko!

hey @anthonybarsotti: it occurs to me maybe you have some ideas here? is it just a "browser thing" that some key events are not interceptable?

for context, key handling is happening here:

https://github.com/monome/maiden/blob/6224a34424b923fe3faf285673a1798631d88d81/app/src/services.js#L70-L78

with listening happening here:

https://github.com/monome/maiden/blob/6224a34424b923fe3faf285673a1798631d88d81/app/src/workspace.js#L56

pq commented 6 years ago

i wonder if trying the editor.blur() and setTimeout() trick described in https://github.com/ajaxorg/ace/issues/3179 isn't worth a shot...

ryanlaws commented 5 years ago

Same issue in Chromium / i3 on Arch

ryanlaws commented 5 years ago

It looks like the problem is that the keybinding provided in services.js applies to the window but does not define handling in the editor. I've had success in the default ACE editor by adding a scriptRun prop to the Editor class and adding the following prop to its JSX render-instantiation of the AceEditor class in editor.js:

commands={[{
  name: 'play',
  bindKey: { win: 'Ctrl-P', mac: 'Ctrl-P' },
  exec: () => { 
    scriptRun && scriptRun(getActiveBuffer());
  }
}]}

Note that this does not appear to apply to the Vim keybindings (whose defaults oddly map this to k for moving up a line). I cannot speak for Emacs as I am completely incompetent in Emacs.

ngwese commented 5 years ago

Good to know - this is an area that hasn’t been touched in awhile. A PR which gets thing working would be most welcome