Capslock on hover notification using VAADIN

When the capslock button is on, I want a
warning message
to be shown on mouse
hover
on the password field.

I found the below piece of code from VAADIN website,

@Connect(CapsLockWarning.class)
public class CapsLockWarningConnector extends AbstractExtensionConnector
{ @Override
protected void extend(ServerConnector target)
{
final Widget passwordWidget = ((ComponentConnector) target).getWidget();
final VOverlay warning = new VOverlay();
warning.setOwner(passwordWidget);
warning.add(new HTML("Caps Lock is enabled!"));
passwordWidget.addDomHandler(new KeyPressHandler()
{
@Override
public void onKeyPress(KeyPressEvent event)
{
if (isEnabled() && isCapsLockOn(event))
{
warning.showRelativeTo(passwordWidget);
} else
{
warning.hide();
}
}
}, KeyPressEvent.getType()); }
private boolean isCapsLockOn(KeyPressEvent e)
{
return e.isShiftKeyDown() ^ Character.isUpperCase(e.getCharCode());
}
}

But the above piece of code depends on pressing any key to determine whether capslock is on or not.

Is there any way to implement this functionality without pressing any keys(except capslock) in vaadin?

you can replace the KeyPressHandler by using MouseOverHandler and MouseOutHandler

Actually if you see the way capslock is checked in the above piece of code…you will see that it depends on
pressing
keys(upper case is checked)