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

Duplicate key events on macOS #734

Closed
chrisduerr opened this issue Dec 5, 2018 · 5 comments
Closed

Duplicate key events on macOS #734

chrisduerr opened this issue Dec 5, 2018 · 5 comments
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos

Comments

@chrisduerr
Copy link
Contributor

It has been reported to Alacritty that in certain circumstances the Paste key is sent multiple times to the winit application.

The relevant bug report in Alacritty can be found here:
alacritty/alacritty#1842

Based on the troubleshooting there, it looks like the key event is actually sent twice, however user-related problems probably can't completely be excluded since there has been noone able to reproduce this issue.

My initial thought was that it might be related to key repeat rate, but that seems to be default.

@francesca64 francesca64 added B - bug Dang, that shouldn't have happened DS - macos C - needs investigation Issue must be confirmed and researched labels Dec 5, 2018
@rrichardson
Copy link

FWIW I can reproduce this issue. As a few others who use the Dvorak keyboard (or other alternate) layouts

@rrichardson
Copy link

rrichardson commented Jan 5, 2019

Interestingly, it is only for Command + Period I can't explain why.

If I remap it to Control + Period it works fine. If I remap it to Command + Comma or any other value, it is fine.

@hobogenized
Copy link

I've found something that might be related. After changing the alacritty config to use "Cmd + ." to do paste and changing my keyboard layout to Dvorak, I found that doing "Cmd + ." according to the Dvorak layout does nothing, but doing "Cmd + v" according to the Dvorak layout will paste twice. "v" on the Dvorak keyboard layout corresponds to "." on the QWERTY keyboard, so there's a chance that keyboard inputs are not processed cleanly according to the current keyboard layout.

@nolanderc
Copy link

I've been digging into the source code for the macOS EventsLoop implementation and found something interesting:

https://github.com/tomaka/winit/blob/8e733543cdc1c8b0ab4172f3fd2d9ef98b23dce1/src/platform/macos/events_loop.rs#L318-L338

It appears as if there once was a bug in AppKit where key-up events weren't being sent to the right window while the Command key was held. To my understanding, however, Command + Period had the opposite behaviour: ignoring key-down events.

The code quoted above attempts to address this bug by inserting the correct key-down event for Command + Period into the stream. But at some point it seems this issue was addressed and events are now being sent twice: once from AppKit and once from the patch.

After some testing: removing the appkit::NSKeyDown branch seems to eliminate all duplicate events.

@kchibisov
Copy link
Member

long resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos
Development

No branches or pull requests

6 participants