Zoilo Gomez

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromZoilo Gomez
ToMe
Subjectcatching keypress events while mouse over plugin
Date24 June 2007 01:29
Thank you for your excellent Javascript tutorial!

I am trying to use Firefox (2.0.0.4), with VLC plugin (sorry!), to create a
simple user interface to zap through a list of video streams. Basically I
want to intercept all keystrokes to implement my own control functions. For
example: I do not like the 'f'-key to cause the plugin to go to full-screen
mode, so I like to catch the 'f'-key and possible do something else with it.

Based on what I have learned from your tutorial, I installed an event
handler (W3C DOM) to catch all keys pressed on a page that uses VLC-plugin,
regardless of where the focus is: window.addEventListener('keypress',
myhandler, true). In this way my handler gets called whenever a key is being
pressed, even when the focus is on an input or on a button.

However, whenever the mouse is over the vlc-plugin window, my handler is not
being called at all ....

The video windows is created using the "<embed>"-tag. Is the embedded video
window is not propagating events? If so, how can I intercept keys when the
mouse is over the video window?

Or am I overlooking something? I cannot imagine that the plugin is able to
overrule the Javascript DOM event model.

Thank you very much in advance for your opinion and time.

Zoilo.
FromMe
ToZoilo Gomez
SubjectRe: catching keypress events while mouse over plugin
Date24 June 2007 10:20
Zoilo,

> However, whenever the mouse is over the vlc-plugin window, my handler is
> not being called at all ....

As always, plugins are really not my strong point, but ...

Plugins are basically in control when you use them. A plugin can tell the
hosting application (your browser) that it has the focus whenever it wants.
When it has focus, the hosting application will not send key/mouse events to
the page, as they are intercepted by the plugin instead.

Your plugin has decided that mouseover means focus, which is wrong on
Windows and Mac, but had always been the default on Unix/Linux window
managers based on X. Even though most window managers allow you to change
that behaviour (many default to click-to-focus, like Windows), plugins do
not use the window manager, and this plugin has chosen to follow the
alternative model.

From a fellow Web developer:

 ---

By default on Unix/Linux, Opera would transfer focus, except if the plugin
triggers the click-to-activate shim.

Firefox usually only transfers focus on click, but it does send mouseover
and mouseout events to the plugin, and if the plugin is smart enough it can
assume it has focus, and start listening.

Konqueror uses XEmbed and is the most civilized one: at least only because
there is a *spec* that describes what goes on.

 ---

Or in other words, if you dislike the behaviour, you can ask the plugin
developers to fix it, but don't hold your breath.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.