@Override public void onKeyDown(final KyPressedEvent evt) { final Accelerator acc = evt.getAccelerator(); if (acc.getKeyCode() == KeyCode.UNDEFINED) return; ModuleInfo moduleInfo = null; // look up the module corresponding to this key press moduleInfo = moduleService.getModuleForAccelerator(acc); // TODO: ask options service whether the default modifier should be forced final boolean addModifierAutomatically = true; if (moduleInfo == null && addModifierAutomatically) { // look up the module corresponding to this key press, plus control final KeyCode keyCode = acc.getKeyCode(); final InputModifiers modifiers = forceDefaultModifier(acc.getModifiers()); final Accelerator modAcc = new Accelerator(keyCode, modifiers); if (!acc.equals(modAcc)) { moduleInfo = moduleService.getModuleForAccelerator(modAcc); } } if (moduleInfo == null) return; // no matching module found // run via command service, so that preprocessors are run moduleService.run(moduleInfo, true, new Object[0]); // FIXME // consume event, so that nothing else tries to handle it evt.consume(); }
@Override public void onKeyDown(final KyPressedEvent evt) { if (evt.getCode() == CODE[index]) { index++; if (index > CODE.length - 2) evt.consume(); if (index == CODE.length) { index = 0; final ThreadService threadService = getContext().getService(ThreadService.class); threadService.run(this); final CommandService commandService = getContext().getService(CommandService.class); commandService.run(COMMAND); } } else index = 0; }