WebBrowserComponent not getting keypresses in VST for certain hosts

I have a plugin that embeds a WebBrowserComponent, and certain key presses are being swallowed by various hosts and not reaching the component.

For example, Reaper only steals certain keys (e.g. enter), Cubase seems to steal a lot more.

Other components (e.g. TextEditor) get the key presses just fine.

I’ve tried calling setWantsKeyboardFocus() and grabKeyboardFocus() but these don’t solve the problem.

I initially thought this was a Windows-specfic issue, but it seems to affect OS X also.

I’m afraid that this is not an easy problem to solve. Plug-in hosts do a lot of hacky key stealing from the VST editor window to make sure things like pressing the spacebar will always start and stop the transport. When the host is catching all the key events there’s no way we can fix this on the plug-in side.

Well, I’ve managed to capture the “stolen” keypresses by installing a message hook using SetWindowsHookEx(). I think JUCE already uses something similar in the plugin client code already, which explains why all the other JUCE components seem to get the keypresses. The problem I have now is I can’t find any way to pass these messages on to the IWebBrowser2 control.

Could you write some custom win32 code to inject key events into the browser’s HWND? This is a bit speculative, and I realise that the WebBrowserComponent deliberately hides away platform specific details like this, but with a bit of hacking you may be able to tunnel through JUCE’s API.

@t0m Yeah, thanks for answering on this! I’m currently stuck trying to get the right HWND to send the WM_CHAR messages to. I can send WM_CHAR to Notepad with SendMessage() but I’m banging my head trying to get the correct handle for the IWebBrowser2 component…

Have you tried a similar approach to that in WebBrowserComponent::focusGained? Besides IOleWindow there are three or four other GUIDs that might work, but I’m afraid I’m unsure which ones.

@t0m Solved it! It was as simple as HWND newHandle = GetFocus(); :slight_smile: If I can get this into a decent state, I’ll share the full code at some point.