MCPcopy
hub / github.com/arduino/Arduino / keyPressed

Method keyPressed

app/src/processing/app/SerialMonitor.java:75–99  ·  view source on GitHub ↗
(KeyEvent e)

Source from the content-addressed store, hash-verified

73 // Add key listener to UP, DOWN, ESC keys for command history traversal.
74 textField.addKeyListener(new KeyAdapter() {
75 @Override
76 public void keyPressed(KeyEvent e) {
77 switch (e.getKeyCode()) {
78
79 // Select previous command.
80 case KeyEvent.VK_UP:
81 if (commandHistory.hasPreviousCommand()) {
82 textField.setText(
83 commandHistory.getPreviousCommand(textField.getText()));
84 }
85 break;
86
87 // Select next command.
88 case KeyEvent.VK_DOWN:
89 if (commandHistory.hasNextCommand()) {
90 textField.setText(commandHistory.getNextCommand());
91 }
92 break;
93
94 // Reset history location, restoring the last unexecuted command.
95 case KeyEvent.VK_ESCAPE:
96 textField.setText(commandHistory.resetHistoryLocation());
97 break;
98 }
99 }
100 });
101 }
102

Callers

nothing calls this directly

Calls 7

hasPreviousCommandMethod · 0.80
getPreviousCommandMethod · 0.80
hasNextCommandMethod · 0.80
getNextCommandMethod · 0.80
resetHistoryLocationMethod · 0.80
getTextMethod · 0.65
setTextMethod · 0.45

Tested by

no test coverage detected