This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
1 Replies Last post: May 4, 2007 2:35 PM by Vladimir Ikryanov  
tobi   5 posts since
Jan 26, 2007
Currently Being Moderated

May 2, 2007 3:42 PM

EventListener - key-events

Hi,

 

I tried to capture key events on document-body. So I added an EventListener to the body-tag. If I press a key, an event is thrown. So: How can I cast it to a KeyEvent or something like this? I want to read the keycode pressed in a webpage...

 

Best regards,

Tobi

Vladimir Ikryanov TeamDev Ltd. 404 posts since
Apr 24, 2006
Currently Being Moderated
1. May 4, 2007 2:35 PM in response to: tobi
Re: EventListener - key-events

Hello Tobi,

 

Unfortunately, JExplorer API doesn't allow to do this yet. But you can receive key code using the following way:

 

    browser.getDocument().getBody().addEventListener("onkeypress", new EventListener()
    {
        public void handleEvent(Event evt)
        {
            if (evt instanceof UIEvent) {
                int keyCode = ((UIEvent) evt).getDetail();
                System.out.println("keyCode = " + keyCode);
            }
        }
    }, false);

We will investigate such ability to add KeyEventListener for HTML element and maybe we will implement this in one of the next version of JExplorer.

 

Regards,

Vladimir

More Like This

  • Retrieving data ...