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

Simulated presses are keyboard dependent #1

Closed
davidfoord1 opened this issue Jul 15, 2024 · 1 comment
Closed

Simulated presses are keyboard dependent #1

davidfoord1 opened this issue Jul 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@davidfoord1
Copy link
Owner

Issue in rstudiovim

Key presses are simulated incorrectly based on keyboard layout. Trying to add a command like:

map \p "0p

What gets types instead is

map \p ~0p

Looks like my en-UK layout is being converted to an en-US layout.

Investigating in KeyboardSimulator dependency.

Language-based issue is raised in the comments of issue #8.

It appears the input to KeyboardSimulator functions are converted to codes based on the fixed table in keyboard_value.R. For example keybd.press(), in main.R, does some cleaning and parsing of the string of buttons, which is then used as a lookup for keyboard_value. The virtual key code and scan code are ultimately pass to the Windows API C++ function keybd_event() in press.cpp.

The main problem is the scan code always being the same as this is hardware-dependent. It would be good to just use the hardware-independent virtual key code.

Possible solution

I didn't think I'd be looking at the Windows API but here we are. The mapVirtualKey family provides a way to convert from scan codes to virtual key codes. sendInput supersedes keybd_event and can send an input based on a virtual key code. It would be good to have KeyboardSimulator updated with these, but could potentially be implemented in rstudiovim.

@davidfoord1 davidfoord1 added the bug Something isn't working label Jul 15, 2024
@davidfoord1
Copy link
Owner Author

Resolved by #2 - Using VkScanKey and SendInput - at least as long as a single keyboard layout is used throughout the session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant