public void update() {
        for(KeyboardHandler kh : removeLater) {
            listeners.remove(kh);
        }
        removeLater.clear();
        for(KeyboardHandler kh : addLater) {
            listeners.add(kh);
        }
        addLater.clear();
        Keyboard.poll();
        while(Keyboard.next()) {
            int keyCode = Keyboard.getEventKey();
            // Ignore the "null" code
            if(keyCode == 0) return;
            boolean state = Keyboard.getEventKeyState();
            long nanotime = Keyboard.getEventNanoseconds();
            char key = Keyboard.getEventCharacter();
            String name = Keyboard.getKeyName(keyCode);
            final InputEvent event = new InputEvent(keyCode,
                    state,
                    nanotime,
                    key,
                    name);
            for(KeyboardHandler handler : listeners) {
                handler.handle(event);
                if(event.isConsumed()) {
                    break;
                }
            }
        }
    }