KeyboardEvent properties don't match real browsers #319
Labels
No labels
area/accessibility
area/dependency
Confirmed
Crash Report
Delayed
Design Issue
Duplicate
Feedback required
Good first issue
kind/bug
kind/cleanup
kind/enhancement
platform/linux
platform/macos
platform/windows
priority/high
Question
Request for Comments
Seeking Other Contributors
Seeking Testers
Won't Fix / By Design
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-obsproject/obs-browser#319
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Operating System Info
Windows 10
Other OS
No response
OBS Studio Version
27.2.4
OBS Studio Version (Other)
No response
OBS Studio Log URL
https://obsproject.com/logs/1RjIPQfX0BqFKJ98
OBS Studio Crash Log URL
No response
Expected Behavior
The KeyboardEvent generated should be similar to that originating in a regular browser. For example, using a standard US layout, typing a colon with the right shift key should generate two events with (among others) the following properties:
Current Behavior
Using the same example of typing a colon, I see the following properties:
From this and other tests, it seems that code is always blank, and location is always 0.
Steps to Reproduce
https://domeventviewer.com/key-event-viewer.html. Leave the other settings unchanged.Anything else we should know?
I saw that there have been similar issues closed, but I'm not sure if they were considered fixed or just as close as we could get. If it's the latter case, I'm sorry for being yet another person to bring this up. The webpage I'm actually using can be modified to use OBS's key values when it detects that it's running in OBS, but then it's still locked to one keyboard layout.
We are more or less at the mercy of CEF here and how it handles these things. Please mind that on Windows, our CEF is quite old (equivalent of Chrome 75) and this alone might make the difference.
You can track progress in updating to a newer CEF release here: https://github.com/obsproject/obs-studio/discussions/3853
This is something I've been trying my best to try and fix over time.
github.com/obsproject/obs-browser@a14ed2feattempts to get it relatively functional on macOS,github.com/obsproject/obs-browser@ae25c36aattempted to fix it on Linux, and I've always tested it on Windows.I also use keycode.info as a smoke test, but I can confirm modifiers are a bit of a nightmare. I admit that I hadn't been testing colon vs semicolon.
It's definitely an area I want to improve further - the challenge is that we go through 3 layers of conversion: first Qt reads it, it gets converted into an
obs_key_t, and then we convert that to something CEF approves of.Additionally, the OBS Interact window doesn't handle held keys or related events - that's the same reason drag & drop cursor events don't work properly.
I'll continue experimenting with this when I have the motivation. Honestly this particular OBS API is a bit of a nightmare to work with.
Edit: Oh god did my recent changes break #236 again? I hope not.
OK, after further testing, recent code did not break this. What I've actually learned is that the
event->textfrom OBS to CEF is correct, but by the time it reaches the webpage it's wrong. I'm not quite sure why.Additionally, the good news is that the "modifiers" match on OBS and CEF, so that particular aspect we don't need to worry about.
Top: Browser Dock

Bottom: Browser Source
I updated the report to indicate what occurs on 27.2.4 (which is almost the same), and I updated the steps to reproduce since keycode.info is no longer accurate. One other thing I noticed (though you probably were aware of it) is that interacting with a browser source through remote debugging gives mostly correct property values.
Also, the modifiers do not match exactly. The modifier states for Shift, Ctrl, and Alt (and their specific properties) are false on keydown and true on keyup of their respective keys. The wording of the spec isn't super clear about that imo, but its examples show them as true on keydown and false on keyup, which is also what happens in remote debugging. The Meta modifier and its property, as well as Caps Lock, Scroll Lock, and Num Lock, are always false. (Meta and its property can be true for events from remote debugging, but the other modifiers will not.)
This seems related to this CEF bug:
https://github.com/chromiumembedded/cef/issues/2597