How can i get keypad inputs like enter or F1? I need to get the textbox content after the enter key is pressed. I need to get too the F1 and other keys in whatever moment.
public static void main(String[] args) throws IOException, InterruptedException {
SpringApplication.run(LanternaApplication.class, args);
TelnetTerminalServer server = new TelnetTerminalServer(2000, Charset.forName("utf8"));
final TelnetTerminal telnetTerminal = server.acceptConnection();
KeyStroke keyPressed = telnetTerminal.readInput();
System.out.println("keyPressed: " + keyPressed.getKeyType());
// Setup screen layers
Screen screen = new TerminalScreen(telnetTerminal);
screen.startScreen();
// Create main panel to hold components
Panel mainPanel = new Panel();
mainPanel.setLayoutManager(new GridLayout(1));
//input
final TextBox tbox = new TextBox(new TerminalSize(40, 1));
tbox.withBorder(Borders.singleLine());
mainPanel.addComponent(tbox);
//label
mainPanel.addComponent(new Label("New Label"));
// Create window to hold the panel
BasicWindow window = new BasicWindow();
window.setComponent(mainPanel);
// Create gui and start gui
MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.DEFAULT));
gui.addWindowAndWait(window) }
I have tried using an infinite loop but i can´t reach it after gui.addWindowAndWait(window);
while(true){
// Read input
KeyStroke keyPressed = telnetTerminal.readInput();
// Check the input for the "tab" key
if (keyPressed.getKeyType() == KeyType.F1){
System.out.println("keyPressed: " + keyPressed.getKeyType());
}
}
Thanks!