我是ReactFX的新手,我正在尝试捕获按下CTRL和C键进行典型的复制操作。
如何有效地将其捕获到流中?这是我到目前为止所能得到的,但它甚至没有编译......
final EventStream<KeyEvent> keysTyped = EventStreams.eventsOf(myTbl, KeyEvent.KEY_TYPED)
.reduceSuccessions((a,b) -> new KeyCodeCombination(a.getCode(),b.getCode()), 500);
答案 0 :(得分:1)
这对我有用:
KeyCombination ctrlC = new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN);
final EventStream<KeyEvent> keysTyped = EventStreams.eventsOf(text, KeyEvent.KEY_PRESSED)
// the following line, if uncommented, will limit the frequency
// of processing ctrl-C to not more than once every 0.5 seconds
// As a side-effect, processing will be delayed by the same amount
// .reduceSuccessions((a, b) -> b, Duration.ofMillis(500))
.filter(ctrlC::match);
keysTyped.subscribe(event -> System.out.println("Ctrl-C pressed!"));