Skip to content

Commit d4e7cd3

Browse files
authored
Merge pull request #1678 from jline/fix/key-binding-docs-1668
fix: Use KeyMap.key() for capability-based key bindings in example (fixes #1668)
2 parents 71f0f98 + 60aaafd commit d4e7cd3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

demo/src/main/java/org/jline/demo/examples/CustomKeyBindingsExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ public static void main(String[] args) throws Exception {
4545
reader.getKeyMaps().get(LineReader.MAIN).bind(new Reference("capitalize-word"), "\u001b\u0063"); // Alt+C
4646

4747
// 5. Bind F5 to clear screen
48+
// Use KeyMap.key() to convert the terminal capability to an actual key sequence
4849
reader.getKeyMaps()
4950
.get(LineReader.MAIN)
50-
.bind(new Reference("clear-screen"), terminal.getStringCapability(Capability.key_f5));
51+
.bind(new Reference("clear-screen"), KeyMap.key(terminal, Capability.key_f5));
5152

5253
// 6. Bind Ctrl+X Ctrl+E to edit-and-execute-command
5354
reader.getKeyMaps()

0 commit comments

Comments
 (0)