static KeyListener functionKeyListener(int functionKeyNr, Runnable action) { ret new KeyAdapter { public void keyReleased(KeyEvent ke) { if (ke.getKeyCode() == KeyEvent.VK_F1+functionKeyNr-1 && ke.getModifiers() == 0) { pcallF(action); } } }; }