webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.37k stars 146 forks source link

Key Events #269

Closed wwderw closed 7 months ago

wwderw commented 8 months ago

Does Webui only handle, essentially, on KeyReleased events or can it handle checking KeyDown type of binding?

fibodevy commented 8 months ago

Only clicks are sent as events to the backend application. You can write your own piece of JS code to do the job.

AlbertShown commented 8 months ago

I guess it only handles mouse ClickReleased by default. I tested it by clicking on a button without release, and no webui event was fired. But, it's so easy to do whatever you want using JavaScript. Example of firing on keyboard key press:

document.addEventListener('keydown', () => {
   my_backend_event();
});
wwderw commented 8 months ago

When I originally had this issue, I did try to use JS to call the backend function. At first I was thinking maybe I had the JS function wrong, so I did the wonderful debug by console.log() and that fired, but the webui.call("myIDHERE") didn't fire. OR if it did, it was after I closed out of the program(it would do printf() after I closed the program and it would do the printf() commiserate with as many times as I clicked the canvas element).

AlbertShown commented 7 months ago

This sounds like a JavaScript issue. What language is used in your backend? Also, if you can share some logs and scripts, that will be helpful.