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

Feature request: Recognise keyboard button presses globally, and pass them to addEventListener in page JS #3

Open
grkblood13 opened this issue Mar 4, 2019 · 1 comment

Comments

@grkblood13
Copy link

hudkit doesn't seem to recognize when buttons are pressed on the keyboard. Here's a simple test page that should be displaying the keycodes.

<html>
<head></head>
<style>
body {
	background-color: #000;
	font-size: 30px;
	font-weight: bold;
	color: #fff;
}
</style>
<body>
<p id='keyCode'></p>
<script>
document.addEventListener('keydown', function(e) {
	document.getElementById("keyCode").innerHTML = e.keyCode;
});
</script>
</body>
</html>
@anko
Copy link
Owner

anko commented Mar 4, 2019

I'd love this too, but I haven't been able to figure out how to make it work.

As it stands, if I make the window able to be focused (by commenting this line and these lines), input events are sent to the webview, but it eats them, and they don't propagate to the desktop, so the window isn't click-through anymore.

I figure it must be possible somehow to hack around with GTK's event propagation functions to do this. Duplicate the event, propagate one to the webview, and the other to the desktop? Maybe. 🤔


Workaround: xkbcat into a WebSocket.

@anko anko changed the title keyboard entries not being recognized Feature request: Recognise keyboard button presses globally, and pass them to addEventListener in page JS Jul 15, 2020
anko added a commit that referenced this issue May 3, 2021
Finally figured out how to do this.  This change makes it possible for
the first time for the overlay window to react to keyboard events, and
so it's possible to make any arbitrary interactive web UI with it!

It's pretty neato.

This is a proof of concept!  There are many minor bugs, like
drag-and-drop completely breaks when trying to drag out of the overlay's
clickable area, and enter/leave events jitter when sweeping the mouse
along edges of the screen.  That kind of thing.

Related to #3 and #5, but not global; no events are duplicated here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants