rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

Rust Playground doesn't deal with re-mapped keys correctly.

Open vext01 opened this issue 7 years ago • 14 comments

Hi,

To cut a long story short, I use a Maltron keyboard to keep RSI at bay. It's a totally bonkers looking thing, but it works.

I didn't like the position of the escape key, and swapped it with the windows key, remapping the key in Xorg with (in my .xsession):

xmodmap -e 'keysym Super_L = Escape'

This works for pretty much everything, but not for the rust playground. I'd like to use the playground in vim mode, but have to reach to the original position of the escape key to exit insert mode. The key remapping is to respected for some reason.

Could the Rust playground take xmodmap re-mappings into account?

vext01 avatar May 08 '18 10:05 vext01

Hi the key mapping is normally handled by the browser, and web page by itself can't detect re-mappings. On which browser did you test this? Could you please check which key code is reported by it, using https://w3c.github.io/uievents/tools/key-event-viewer.html?

nightwing avatar May 09 '18 18:05 nightwing

Could the Rust playground take xmodmap re-mappings into account?

I'm equally as surprised as @nightwing, as this should be handled by the OS / browser. On macOS, for example, I've remapped my Caps Lock key to Control and that works fine.

shepmaster avatar May 09 '18 19:05 shepmaster

My two cents: I use the neo-layout, which remaps everything and adds the weirdest sort of different mappings (e.g. CapsLock+Shift+w to ω) and it works just fine.

Regarding browsers: I use vivaldi mainly, but it has problems as it still handles keyevents even though the underlying javascript already consumed them. For exmaple in Vim-mode if I press Ctrl+R, first the vim-binding is executed (redo), then by window refreshes due to vivaldi still handling it as reload. In Firefox this doesn't occur and everything works as expected.

oberien avatar May 09 '18 20:05 oberien

I'm not at the computer with the Maltron keyboard today, so I can't run the key test just yet, but the system in question is running OpenBSD-current/amd64 and a recent version of Firefox.

When I'm next in front of that system I'll update this issue.

Thanks

vext01 avatar May 10 '18 09:05 vext01

Firefox

firefox

Chromium

chromium


So there is some difference.

Escape works fine in the Rust playground on chromium on this system, but not in firefox. In firefox I must press the key's pre-remapped location on the keyboard.

vext01 avatar May 23 '18 15:05 vext01

DId any of that info help? Cheers

vext01 avatar May 29 '18 11:05 vext01

I was having a similar issue trying to escape from insert mode using either <esc>, <Ctr-[> or <Ctr-l>. I was only able to get it to work using <C-c>.

I used the keyboard input tool mentioned above. It's a great tool. The result for me however, is that Firefox (nor chrome) would record my use of the <esc> key.

Is this something worth noting in the documentation? It took me a while to figure out how to use my vim preference in the Rust Playground... without being able to escape the insert mode, the feature is rendered much less useful.

EdmundsEcho avatar Jun 03 '19 13:06 EdmundsEcho

Can you provide reproduction steps? Once I set the playground into Vim mode:

image

I was able to enter edit mode and exit it:

insert

shepmaster avatar Jun 03 '19 15:06 shepmaster

Thank you for looking into this. Here is a video of what is happening at my end... I'm not as proficient as you seem to be with video production... this said, you should see that I'm in Vim mode. I try to use while in insert mode to no avail. However, <C-c> works.

https://im.ezgif.com/tmp/ezgif-1-f1f4182f809d.gif

EdmundsEcho avatar Jun 05 '19 00:06 EdmundsEcho

I don't know what changed, but my re-mapped escape key now works in vim mode on the rust playground under firefox.

vext01 avatar Jun 17 '19 16:06 vext01

It would be invaluable if it was possible to remap esc in vim mode to a sequence of characters... almost all vim users out there use either fd, jk, jj, kj or one of those...

Would that be feasible?

aldanor avatar Jul 16 '19 21:07 aldanor

It is already possible to remap vim keys by typing : imap jj <Esc>. To remap from javascript require("ace/keyboard/vim").Vim.map("xx", "<Esc>", "insert") can be used.

nightwing avatar Jul 19 '19 17:07 nightwing

@aldanor I'm not a vi/vim user so I only understand the very basics of what you are asking :-) Does what @nightwing suggested work for your case?

shepmaster avatar Jul 21 '19 17:07 shepmaster

@shepmaster Yes, the solution @nightwing suggests would be really helpful. The key to the spec is the ability to map 2 char to the escape functionality (per the "xx" described). I truly think this is one of those "minimum input, maximum output" fixes... at least I can attest to the value of the output :))

EdmundsEcho avatar Jan 14 '21 15:01 EdmundsEcho