Java 类org.w3c.dom.events.KeyboardEvent 实例源码

项目:dragome-examples    文件:ExampleView.java   
public ExampleView(Content<?> content)
{
    cameraRenderer= new CanvasDebugDraw((Element)content.getValue());
    exampleRunner= new ExampleRunner(cameraRenderer);
    HTMLCanvasElement canvas= cameraRenderer.getCanvas();

    EventDispatcherImpl.setEventListener(canvas, new EventListener()
    {
        public void handleEvent(Event event)
        {
            if (event instanceof MouseEvent)
            {
                MouseEvent mouseEvent= (MouseEvent) event;

                if (event.getType().equals("mousedown"))
                    onMouseDown(mouseEvent);
                else if (event.getType().equals("mouseup"))
                    onMouseUp(mouseEvent);
                else if (event.getType().equals("mousemove"))
                    onMouseMove(mouseEvent);
            }
            else if (event instanceof KeyboardEvent)
            {
                KeyboardEvent keyboardEvent= (KeyboardEvent) event;

                if (event.getType().equals("keypress"))
                    onKeyPress(keyboardEvent);
                else if (event.getType().equals("keyup"))
                    onKeyUp(keyboardEvent);
                else if (event.getType().equals("keydown"))
                    onKeyDown(keyboardEvent);
            }
        }
    }, "mousedown", "mouseup", "mousemove", "keypress", "keyup", "keydown");
}
项目:dragome-examples    文件:ExampleView.java   
protected void onKeyPress(KeyboardEvent keyboardEvent)
{
    keyboardEvent.preventDefault();
    ExampleKeyEvent eme= new ExampleKeyEvent(ExampleKeyEvent.KEY_EVENT_TYPE_PRESS, keyboardEvent.getKeyIdentifier().charAt(0));
    eme.dispatch(exampleRunner);
}
项目:dragome-examples    文件:ExampleView.java   
protected void onKeyDown(KeyboardEvent keyboardEvent)
{
    keyboardEvent.preventDefault();
    ExampleKeyEvent eme= new ExampleKeyEvent(ExampleKeyEvent.KEY_EVENT_TYPE_DOWN, keyboardEvent.getKeyIdentifier().charAt(0));
    eme.dispatch(exampleRunner);
}
项目:dragome-examples    文件:ExampleView.java   
protected void onKeyUp(KeyboardEvent keyboardEvent)
{
    keyboardEvent.preventDefault();
    ExampleKeyEvent eme= new ExampleKeyEvent(ExampleKeyEvent.KEY_EVENT_TYPE_UP, keyboardEvent.getKeyIdentifier().charAt(0));
    eme.dispatch(exampleRunner);
}