Reputation: 21
I'd like to develop a voice chat application that would run inside of a web browser. My main concern is implementing push-to-talk functionality when the site doesn't have focus.
Say, for example, that the user is playing a video game, and they decide to press and hold the "C" key to indicate that they'd like to talk. I want my web application to respond to that, even though it wouldn't have focus at the time. Is this possible (using any language)?
Upvotes: 2
Views: 253
Reputation: 21541
It isn't necessarily impossible, but as of right now, it is.
Keyboard events target the currently-in-focus DOM element. Currently, all web browsers will remove focus from any DOM element when the browser is minimized, or when the user clicks outside of the page.
With the increased focus on web-app-support in modern browsers, this rule could theoretically change, but I haven't heard of any browser vendors considering it.
Upvotes: 1
Reputation: 86729
I can't see any way of doing this without installing some client side functionality (such as an ActiveX component or similar) - a browser won't normall allow JavaScript or similar code to handle keypresses when the window is not active as this would be a security vulnerability.
Upvotes: 2