From dedaa23c5c4415b1bccc1e20e94aa19d20bffb5d Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 15:06:52 -0400 Subject: [PATCH 1/9] feat: add support for function keys, F1 through F12 --- key.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/key.go b/key.go index 97144444ec..25b3efacdc 100644 --- a/key.go +++ b/key.go @@ -200,6 +200,18 @@ const ( KeyPgUp KeyPgDown KeyDelete + KeyF1 + KeyF2 + KeyF3 + KeyF4 + KeyF5 + KeyF6 + KeyF7 + KeyF8 + KeyF9 + KeyF10 + KeyF11 + KeyF12 ) // Mapping for control keys to friendly consts. @@ -249,6 +261,19 @@ var keyNames = map[KeyType]string{ KeyEnd: "end", KeyPgUp: "pgup", KeyPgDown: "pgdown", + KeyDelete: "delete", + KeyF1: "f1", + KeyF2: "f2", + KeyF3: "f3", + KeyF4: "f4", + KeyF5: "f5", + KeyF6: "f6", + KeyF7: "f7", + KeyF8: "f8", + KeyF9: "f9", + KeyF10: "f10", + KeyF11: "f11", + KeyF12: "f12", } // Mapping for sequences to consts. @@ -259,8 +284,7 @@ var sequences = map[string]KeyType{ "\x1b[D": KeyLeft, } -// Mapping for hex codes to consts. Unclear why these won't register as -// sequences. +// Mapping for hex codes to consts. var hexes = map[string]Key{ "1b5b5a": {Type: KeyShiftTab}, "1b5b337e": {Type: KeyDelete}, @@ -285,6 +309,32 @@ var hexes = map[string]Key{ "1b5b313b3343": {Type: KeyRight, Alt: true}, "1b5b313b3344": {Type: KeyLeft, Alt: true}, + // Function keys + "1b4f50": {Type: KeyF1, Alt: false}, + "1b5b313b3350": {Type: KeyF1, Alt: true}, + "1b4f51": {Type: KeyF2, Alt: false}, + "1b5b313b3351": {Type: KeyF2, Alt: true}, + "1b4f52": {Type: KeyF3, Alt: false}, + "1b5b313b3352": {Type: KeyF3, Alt: true}, + "1b4f53": {Type: KeyF4, Alt: false}, + "1b5b313b3353": {Type: KeyF4, Alt: true}, + "1b5b31357e": {Type: KeyF5, Alt: false}, + "1b5b31353b337e": {Type: KeyF5, Alt: true}, + "1b5b31377e": {Type: KeyF6, Alt: false}, + "1b5b31373b337e": {Type: KeyF6, Alt: true}, + "1b5b31387e": {Type: KeyF7, Alt: false}, + "1b5b31383b337e": {Type: KeyF7, Alt: true}, + "1b5b31397e": {Type: KeyF8, Alt: false}, + "1b5b31393b337e": {Type: KeyF8, Alt: true}, + "1b5b32307e": {Type: KeyF9, Alt: false}, + "1b5b32303b337e": {Type: KeyF9, Alt: true}, + "1b5b32317e": {Type: KeyF10, Alt: false}, + "1b5b32313b337e": {Type: KeyF10, Alt: true}, + "1b5b32337e": {Type: KeyF11, Alt: false}, + "1b5b32333b337e": {Type: KeyF11, Alt: true}, + "1b5b32347e": {Type: KeyF12, Alt: false}, + "1b5b32343b337e": {Type: KeyF12, Alt: true}, + // Powershell "1b4f41": {Type: KeyUp, Alt: false}, "1b4f42": {Type: KeyDown, Alt: false}, From 3575a05339a741065fafa3c60769214ed0b4fa5d Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 15:11:04 -0400 Subject: [PATCH 2/9] chore: remove extraneous alt key definitions --- key.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/key.go b/key.go index 25b3efacdc..2bfb01457e 100644 --- a/key.go +++ b/key.go @@ -310,29 +310,29 @@ var hexes = map[string]Key{ "1b5b313b3344": {Type: KeyLeft, Alt: true}, // Function keys - "1b4f50": {Type: KeyF1, Alt: false}, + "1b4f50": {Type: KeyF1}, "1b5b313b3350": {Type: KeyF1, Alt: true}, - "1b4f51": {Type: KeyF2, Alt: false}, + "1b4f51": {Type: KeyF2}, "1b5b313b3351": {Type: KeyF2, Alt: true}, - "1b4f52": {Type: KeyF3, Alt: false}, + "1b4f52": {Type: KeyF3}, "1b5b313b3352": {Type: KeyF3, Alt: true}, - "1b4f53": {Type: KeyF4, Alt: false}, + "1b4f53": {Type: KeyF4}, "1b5b313b3353": {Type: KeyF4, Alt: true}, - "1b5b31357e": {Type: KeyF5, Alt: false}, + "1b5b31357e": {Type: KeyF5}, "1b5b31353b337e": {Type: KeyF5, Alt: true}, - "1b5b31377e": {Type: KeyF6, Alt: false}, + "1b5b31377e": {Type: KeyF6}, "1b5b31373b337e": {Type: KeyF6, Alt: true}, - "1b5b31387e": {Type: KeyF7, Alt: false}, + "1b5b31387e": {Type: KeyF7}, "1b5b31383b337e": {Type: KeyF7, Alt: true}, - "1b5b31397e": {Type: KeyF8, Alt: false}, + "1b5b31397e": {Type: KeyF8}, "1b5b31393b337e": {Type: KeyF8, Alt: true}, - "1b5b32307e": {Type: KeyF9, Alt: false}, + "1b5b32307e": {Type: KeyF9}, "1b5b32303b337e": {Type: KeyF9, Alt: true}, - "1b5b32317e": {Type: KeyF10, Alt: false}, + "1b5b32317e": {Type: KeyF10}, "1b5b32313b337e": {Type: KeyF10, Alt: true}, - "1b5b32337e": {Type: KeyF11, Alt: false}, + "1b5b32337e": {Type: KeyF11}, "1b5b32333b337e": {Type: KeyF11, Alt: true}, - "1b5b32347e": {Type: KeyF12, Alt: false}, + "1b5b32347e": {Type: KeyF12}, "1b5b32343b337e": {Type: KeyF12, Alt: true}, // Powershell From 2ce53280ef7b1ae92f6ea0ee90bd8aff0abaf50e Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 15:35:02 -0400 Subject: [PATCH 3/9] feat: support function keys F13 through F20 --- key.go | 56 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/key.go b/key.go index 2bfb01457e..17ed00fac1 100644 --- a/key.go +++ b/key.go @@ -212,6 +212,14 @@ const ( KeyF10 KeyF11 KeyF12 + KeyF13 + KeyF14 + KeyF15 + KeyF16 + KeyF17 + KeyF18 + KeyF19 + KeyF20 ) // Mapping for control keys to friendly consts. @@ -274,14 +282,42 @@ var keyNames = map[KeyType]string{ KeyF10: "f10", KeyF11: "f11", KeyF12: "f12", + KeyF13: "f13", + KeyF14: "f14", + KeyF15: "f15", + KeyF16: "f16", + KeyF17: "f17", + KeyF18: "f18", + KeyF19: "f19", + KeyF20: "f20", } // Mapping for sequences to consts. var sequences = map[string]KeyType{ - "\x1b[A": KeyUp, - "\x1b[B": KeyDown, - "\x1b[C": KeyRight, - "\x1b[D": KeyLeft, + "\x1b[A": KeyUp, + "\x1b[B": KeyDown, + "\x1b[C": KeyRight, + "\x1b[D": KeyLeft, + "\x1bOP": KeyF1, + "\x1bOQ": KeyF2, + "\x1bOR": KeyF3, + "\x1bOS": KeyF4, + "\x1b[15~": KeyF5, + "\x1b[17~": KeyF6, + "\x1b[18~": KeyF7, + "\x1b[19~": KeyF8, + "\x1b[20~": KeyF9, + "\x1b[21~": KeyF10, + "\x1b[23~": KeyF11, + "\x1b[24~": KeyF12, + "\x1b[1;2P": KeyF13, + "\x1b[1;2Q": KeyF14, + "\x1b[1;2R": KeyF15, + "\x1b[1;2S": KeyF16, + "\x1b[15;2~": KeyF17, + "\x1b[17;2~": KeyF18, + "\x1b[18;2~": KeyF19, + "\x1b[19;2~": KeyF20, } // Mapping for hex codes to consts. @@ -310,29 +346,17 @@ var hexes = map[string]Key{ "1b5b313b3344": {Type: KeyLeft, Alt: true}, // Function keys - "1b4f50": {Type: KeyF1}, "1b5b313b3350": {Type: KeyF1, Alt: true}, - "1b4f51": {Type: KeyF2}, "1b5b313b3351": {Type: KeyF2, Alt: true}, - "1b4f52": {Type: KeyF3}, "1b5b313b3352": {Type: KeyF3, Alt: true}, - "1b4f53": {Type: KeyF4}, "1b5b313b3353": {Type: KeyF4, Alt: true}, - "1b5b31357e": {Type: KeyF5}, "1b5b31353b337e": {Type: KeyF5, Alt: true}, - "1b5b31377e": {Type: KeyF6}, "1b5b31373b337e": {Type: KeyF6, Alt: true}, - "1b5b31387e": {Type: KeyF7}, "1b5b31383b337e": {Type: KeyF7, Alt: true}, - "1b5b31397e": {Type: KeyF8}, "1b5b31393b337e": {Type: KeyF8, Alt: true}, - "1b5b32307e": {Type: KeyF9}, "1b5b32303b337e": {Type: KeyF9, Alt: true}, - "1b5b32317e": {Type: KeyF10}, "1b5b32313b337e": {Type: KeyF10, Alt: true}, - "1b5b32337e": {Type: KeyF11}, "1b5b32333b337e": {Type: KeyF11, Alt: true}, - "1b5b32347e": {Type: KeyF12}, "1b5b32343b337e": {Type: KeyF12, Alt: true}, // Powershell From ceb7a824658d1e29114f0ffb5ea0c46a03027d76 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 15:57:00 -0400 Subject: [PATCH 4/9] feat: add function key support for urxvt, F1 through F20 --- key.go | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/key.go b/key.go index 17ed00fac1..ae7a53f859 100644 --- a/key.go +++ b/key.go @@ -294,10 +294,12 @@ var keyNames = map[KeyType]string{ // Mapping for sequences to consts. var sequences = map[string]KeyType{ - "\x1b[A": KeyUp, - "\x1b[B": KeyDown, - "\x1b[C": KeyRight, - "\x1b[D": KeyLeft, + "\x1b[A": KeyUp, + "\x1b[B": KeyDown, + "\x1b[C": KeyRight, + "\x1b[D": KeyLeft, + + // Function keys "\x1bOP": KeyF1, "\x1bOQ": KeyF2, "\x1bOR": KeyF3, @@ -318,6 +320,28 @@ var sequences = map[string]KeyType{ "\x1b[17;2~": KeyF18, "\x1b[18;2~": KeyF19, "\x1b[19;2~": KeyF20, + + // Function keys, urxvt + "\x1b[11": KeyF1, + "\x1b[12": KeyF2, + "\x1b[13": KeyF3, + "\x1b[14": KeyF4, + "\x1b[15": KeyF5, + "\x1b[17": KeyF6, + "\x1b[18": KeyF7, + "\x1b[19": KeyF8, + "\x1b[20": KeyF9, + "\x1b[21": KeyF10, + "\x1b[23": KeyF11, + "\x1b[24": KeyF12, + "\x1b[25": KeyF13, + "\x1b[26": KeyF14, + "\x1b[28": KeyF15, + "\x1b[29": KeyF16, + "\x1b[31": KeyF17, + "\x1b[32": KeyF18, + "\x1b[33": KeyF19, + "\x1b[34": KeyF20, } // Mapping for hex codes to consts. From 7ea7af2f5df8454c8f9f8236d074f0cbbfba7c40 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 16:21:22 -0400 Subject: [PATCH 5/9] chore: read function keys with alt modifier as sequences --- key.go | 125 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/key.go b/key.go index ae7a53f859..1f6f25d5a6 100644 --- a/key.go +++ b/key.go @@ -293,58 +293,72 @@ var keyNames = map[KeyType]string{ } // Mapping for sequences to consts. -var sequences = map[string]KeyType{ - "\x1b[A": KeyUp, - "\x1b[B": KeyDown, - "\x1b[C": KeyRight, - "\x1b[D": KeyLeft, +var sequences = map[string]Key{ + "\x1b[A": {Type: KeyUp}, + "\x1b[B": {Type: KeyDown}, + "\x1b[C": {Type: KeyRight}, + "\x1b[D": {Type: KeyLeft}, // Function keys - "\x1bOP": KeyF1, - "\x1bOQ": KeyF2, - "\x1bOR": KeyF3, - "\x1bOS": KeyF4, - "\x1b[15~": KeyF5, - "\x1b[17~": KeyF6, - "\x1b[18~": KeyF7, - "\x1b[19~": KeyF8, - "\x1b[20~": KeyF9, - "\x1b[21~": KeyF10, - "\x1b[23~": KeyF11, - "\x1b[24~": KeyF12, - "\x1b[1;2P": KeyF13, - "\x1b[1;2Q": KeyF14, - "\x1b[1;2R": KeyF15, - "\x1b[1;2S": KeyF16, - "\x1b[15;2~": KeyF17, - "\x1b[17;2~": KeyF18, - "\x1b[18;2~": KeyF19, - "\x1b[19;2~": KeyF20, + "\x1bOP": {Type: KeyF1}, // vt100 + "\x1bOQ": {Type: KeyF2}, // vt100 + "\x1bOR": {Type: KeyF3}, // vt100 + "\x1bOS": {Type: KeyF4}, // vt100 + "\x1b[15~": {Type: KeyF5}, + "\x1b[17~": {Type: KeyF6}, + "\x1b[18~": {Type: KeyF7}, + "\x1b[19~": {Type: KeyF8}, + "\x1b[20~": {Type: KeyF9}, + "\x1b[21~": {Type: KeyF10}, + "\x1b[23~": {Type: KeyF11}, + "\x1b[24~": {Type: KeyF12}, + "\x1b[1;2P": {Type: KeyF13}, + "\x1b[1;2Q": {Type: KeyF14}, + "\x1b[1;2R": {Type: KeyF15}, + "\x1b[1;2S": {Type: KeyF16}, + "\x1b[15;2~": {Type: KeyF17}, + "\x1b[17;2~": {Type: KeyF18}, + "\x1b[18;2~": {Type: KeyF19}, + "\x1b[19;2~": {Type: KeyF20}, + + // Function keys with the alt modifier + "\x1b[1;3P": {Type: KeyF1, Alt: true}, + "\x1b[1;3Q": {Type: KeyF2, Alt: true}, + "\x1b[1;3R": {Type: KeyF3, Alt: true}, + "\x1b[1;3S": {Type: KeyF4, Alt: true}, + "\x1b[15;3~": {Type: KeyF5, Alt: true}, + "\x1b[17;3~": {Type: KeyF6, Alt: true}, + "\x1b[18;3~": {Type: KeyF7, Alt: true}, + "\x1b[19;3~": {Type: KeyF8, Alt: true}, + "\x1b[20;3~": {Type: KeyF9, Alt: true}, + "\x1b[21;3~": {Type: KeyF10, Alt: true}, + "\x1b[23;3~": {Type: KeyF11, Alt: true}, + "\x1b[24;3~": {Type: KeyF12, Alt: true}, // Function keys, urxvt - "\x1b[11": KeyF1, - "\x1b[12": KeyF2, - "\x1b[13": KeyF3, - "\x1b[14": KeyF4, - "\x1b[15": KeyF5, - "\x1b[17": KeyF6, - "\x1b[18": KeyF7, - "\x1b[19": KeyF8, - "\x1b[20": KeyF9, - "\x1b[21": KeyF10, - "\x1b[23": KeyF11, - "\x1b[24": KeyF12, - "\x1b[25": KeyF13, - "\x1b[26": KeyF14, - "\x1b[28": KeyF15, - "\x1b[29": KeyF16, - "\x1b[31": KeyF17, - "\x1b[32": KeyF18, - "\x1b[33": KeyF19, - "\x1b[34": KeyF20, + "\x1b[11": {Type: KeyF1}, + "\x1b[12": {Type: KeyF2}, + "\x1b[13": {Type: KeyF3}, + "\x1b[14": {Type: KeyF4}, + "\x1b[15": {Type: KeyF5}, + "\x1b[17": {Type: KeyF6}, + "\x1b[18": {Type: KeyF7}, + "\x1b[19": {Type: KeyF8}, + "\x1b[20": {Type: KeyF9}, + "\x1b[21": {Type: KeyF10}, + "\x1b[23": {Type: KeyF11}, + "\x1b[24": {Type: KeyF12}, + "\x1b[25": {Type: KeyF13}, + "\x1b[26": {Type: KeyF14}, + "\x1b[28": {Type: KeyF15}, + "\x1b[29": {Type: KeyF16}, + "\x1b[31": {Type: KeyF17}, + "\x1b[32": {Type: KeyF18}, + "\x1b[33": {Type: KeyF19}, + "\x1b[34": {Type: KeyF20}, } -// Mapping for hex codes to consts. +// Mappings for hex codes to keys. var hexes = map[string]Key{ "1b5b5a": {Type: KeyShiftTab}, "1b5b337e": {Type: KeyDelete}, @@ -369,20 +383,6 @@ var hexes = map[string]Key{ "1b5b313b3343": {Type: KeyRight, Alt: true}, "1b5b313b3344": {Type: KeyLeft, Alt: true}, - // Function keys - "1b5b313b3350": {Type: KeyF1, Alt: true}, - "1b5b313b3351": {Type: KeyF2, Alt: true}, - "1b5b313b3352": {Type: KeyF3, Alt: true}, - "1b5b313b3353": {Type: KeyF4, Alt: true}, - "1b5b31353b337e": {Type: KeyF5, Alt: true}, - "1b5b31373b337e": {Type: KeyF6, Alt: true}, - "1b5b31383b337e": {Type: KeyF7, Alt: true}, - "1b5b31393b337e": {Type: KeyF8, Alt: true}, - "1b5b32303b337e": {Type: KeyF9, Alt: true}, - "1b5b32313b337e": {Type: KeyF10, Alt: true}, - "1b5b32333b337e": {Type: KeyF11, Alt: true}, - "1b5b32343b337e": {Type: KeyF12, Alt: true}, - // Powershell "1b4f41": {Type: KeyUp, Alt: false}, "1b4f42": {Type: KeyDown, Alt: false}, @@ -413,9 +413,10 @@ func readInputs(input io.Reader) ([]Msg, error) { } // Is it a special sequence, like an arrow key? - if k, ok := sequences[string(buf[:numBytes])]; ok { + seq := string(buf[:numBytes]) + if k, ok := sequences[seq]; ok { return []Msg{ - KeyMsg(Key{Type: k}), + KeyMsg(k), }, nil } From 9be9d64ccd2a11385ae05d3edb6511cd98dbe2f3 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 21:43:02 -0400 Subject: [PATCH 6/9] fix: optimize sequence lookup per the linter --- key.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/key.go b/key.go index 1f6f25d5a6..bed5b2bdd4 100644 --- a/key.go +++ b/key.go @@ -413,8 +413,7 @@ func readInputs(input io.Reader) ([]Msg, error) { } // Is it a special sequence, like an arrow key? - seq := string(buf[:numBytes]) - if k, ok := sequences[seq]; ok { + if k, ok := sequences[string(buf[:numBytes])]; ok { return []Msg{ KeyMsg(k), }, nil From 289524db614df86d52ff83dae0288bd75b27aa1c Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 22:19:01 -0400 Subject: [PATCH 7/9] fix: correct urxvt function keys --- key.go | 64 +++++++++++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/key.go b/key.go index bed5b2bdd4..2f5736a49b 100644 --- a/key.go +++ b/key.go @@ -299,19 +299,19 @@ var sequences = map[string]Key{ "\x1b[C": {Type: KeyRight}, "\x1b[D": {Type: KeyLeft}, - // Function keys - "\x1bOP": {Type: KeyF1}, // vt100 - "\x1bOQ": {Type: KeyF2}, // vt100 - "\x1bOR": {Type: KeyF3}, // vt100 - "\x1bOS": {Type: KeyF4}, // vt100 - "\x1b[15~": {Type: KeyF5}, - "\x1b[17~": {Type: KeyF6}, - "\x1b[18~": {Type: KeyF7}, - "\x1b[19~": {Type: KeyF8}, - "\x1b[20~": {Type: KeyF9}, - "\x1b[21~": {Type: KeyF10}, - "\x1b[23~": {Type: KeyF11}, - "\x1b[24~": {Type: KeyF12}, + // Function keys, X11 + "\x1bOP": {Type: KeyF1}, // vt100 + "\x1bOQ": {Type: KeyF2}, // vt100 + "\x1bOR": {Type: KeyF3}, // vt100 + "\x1bOS": {Type: KeyF4}, // vt100 + "\x1b[15~": {Type: KeyF5}, // also urxvt + "\x1b[17~": {Type: KeyF6}, // also urxvt + "\x1b[18~": {Type: KeyF7}, // also urxvt + "\x1b[19~": {Type: KeyF8}, // also urxvt + "\x1b[20~": {Type: KeyF9}, // also urxvt + "\x1b[21~": {Type: KeyF10}, // also urxvt + "\x1b[23~": {Type: KeyF11}, // also urxvt + "\x1b[24~": {Type: KeyF12}, // also urxvt "\x1b[1;2P": {Type: KeyF13}, "\x1b[1;2Q": {Type: KeyF14}, "\x1b[1;2R": {Type: KeyF15}, @@ -321,7 +321,21 @@ var sequences = map[string]Key{ "\x1b[18;2~": {Type: KeyF19}, "\x1b[19;2~": {Type: KeyF20}, - // Function keys with the alt modifier + // Function keys, urxvt + "\x1b[11~": {Type: KeyF1}, + "\x1b[12~": {Type: KeyF2}, + "\x1b[13~": {Type: KeyF3}, + "\x1b[14~": {Type: KeyF4}, + "\x1b[25~": {Type: KeyF13}, + "\x1b[26~": {Type: KeyF14}, + "\x1b[28~": {Type: KeyF15}, + "\x1b[29~": {Type: KeyF16}, + "\x1b[31~": {Type: KeyF17}, + "\x1b[32~": {Type: KeyF18}, + "\x1b[33~": {Type: KeyF19}, + "\x1b[34~": {Type: KeyF20}, + + // Function keys with the alt modifier, X11 "\x1b[1;3P": {Type: KeyF1, Alt: true}, "\x1b[1;3Q": {Type: KeyF2, Alt: true}, "\x1b[1;3R": {Type: KeyF3, Alt: true}, @@ -334,28 +348,6 @@ var sequences = map[string]Key{ "\x1b[21;3~": {Type: KeyF10, Alt: true}, "\x1b[23;3~": {Type: KeyF11, Alt: true}, "\x1b[24;3~": {Type: KeyF12, Alt: true}, - - // Function keys, urxvt - "\x1b[11": {Type: KeyF1}, - "\x1b[12": {Type: KeyF2}, - "\x1b[13": {Type: KeyF3}, - "\x1b[14": {Type: KeyF4}, - "\x1b[15": {Type: KeyF5}, - "\x1b[17": {Type: KeyF6}, - "\x1b[18": {Type: KeyF7}, - "\x1b[19": {Type: KeyF8}, - "\x1b[20": {Type: KeyF9}, - "\x1b[21": {Type: KeyF10}, - "\x1b[23": {Type: KeyF11}, - "\x1b[24": {Type: KeyF12}, - "\x1b[25": {Type: KeyF13}, - "\x1b[26": {Type: KeyF14}, - "\x1b[28": {Type: KeyF15}, - "\x1b[29": {Type: KeyF16}, - "\x1b[31": {Type: KeyF17}, - "\x1b[32": {Type: KeyF18}, - "\x1b[33": {Type: KeyF19}, - "\x1b[34": {Type: KeyF20}, } // Mappings for hex codes to keys. From f9a934a9026c7821eb8048b0762d04e1ca374717 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 19 Mar 2022 22:21:07 -0400 Subject: [PATCH 8/9] docs: tiny comment improvements --- key.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/key.go b/key.go index 2f5736a49b..33d4bf3cbe 100644 --- a/key.go +++ b/key.go @@ -292,7 +292,7 @@ var keyNames = map[KeyType]string{ KeyF20: "f20", } -// Mapping for sequences to consts. +// Sequence mappings. var sequences = map[string]Key{ "\x1b[A": {Type: KeyUp}, "\x1b[B": {Type: KeyDown}, @@ -350,7 +350,7 @@ var sequences = map[string]Key{ "\x1b[24;3~": {Type: KeyF12, Alt: true}, } -// Mappings for hex codes to keys. +// Hex code mappings. var hexes = map[string]Key{ "1b5b5a": {Type: KeyShiftTab}, "1b5b337e": {Type: KeyDelete}, From a54f33bed349aea139fe9d6f824fffb0d9f7374e Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sun, 20 Mar 2022 21:24:55 -0400 Subject: [PATCH 9/9] feat: support function keys with alt modifiers in urxvt --- key.go | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/key.go b/key.go index 33d4bf3cbe..a0ceea6bbe 100644 --- a/key.go +++ b/key.go @@ -321,6 +321,20 @@ var sequences = map[string]Key{ "\x1b[18;2~": {Type: KeyF19}, "\x1b[19;2~": {Type: KeyF20}, + // Function keys with the alt modifier, X11 + "\x1b[1;3P": {Type: KeyF1, Alt: true}, + "\x1b[1;3Q": {Type: KeyF2, Alt: true}, + "\x1b[1;3R": {Type: KeyF3, Alt: true}, + "\x1b[1;3S": {Type: KeyF4, Alt: true}, + "\x1b[15;3~": {Type: KeyF5, Alt: true}, + "\x1b[17;3~": {Type: KeyF6, Alt: true}, + "\x1b[18;3~": {Type: KeyF7, Alt: true}, + "\x1b[19;3~": {Type: KeyF8, Alt: true}, + "\x1b[20;3~": {Type: KeyF9, Alt: true}, + "\x1b[21;3~": {Type: KeyF10, Alt: true}, + "\x1b[23;3~": {Type: KeyF11, Alt: true}, + "\x1b[24;3~": {Type: KeyF12, Alt: true}, + // Function keys, urxvt "\x1b[11~": {Type: KeyF1}, "\x1b[12~": {Type: KeyF2}, @@ -335,19 +349,19 @@ var sequences = map[string]Key{ "\x1b[33~": {Type: KeyF19}, "\x1b[34~": {Type: KeyF20}, - // Function keys with the alt modifier, X11 - "\x1b[1;3P": {Type: KeyF1, Alt: true}, - "\x1b[1;3Q": {Type: KeyF2, Alt: true}, - "\x1b[1;3R": {Type: KeyF3, Alt: true}, - "\x1b[1;3S": {Type: KeyF4, Alt: true}, - "\x1b[15;3~": {Type: KeyF5, Alt: true}, - "\x1b[17;3~": {Type: KeyF6, Alt: true}, - "\x1b[18;3~": {Type: KeyF7, Alt: true}, - "\x1b[19;3~": {Type: KeyF8, Alt: true}, - "\x1b[20;3~": {Type: KeyF9, Alt: true}, - "\x1b[21;3~": {Type: KeyF10, Alt: true}, - "\x1b[23;3~": {Type: KeyF11, Alt: true}, - "\x1b[24;3~": {Type: KeyF12, Alt: true}, + // Function keys with the alt modifier, urxvt + "\x1b\x1b[11~": {Type: KeyF1, Alt: true}, + "\x1b\x1b[12~": {Type: KeyF2, Alt: true}, + "\x1b\x1b[13~": {Type: KeyF3, Alt: true}, + "\x1b\x1b[14~": {Type: KeyF4, Alt: true}, + "\x1b\x1b[25~": {Type: KeyF13, Alt: true}, + "\x1b\x1b[26~": {Type: KeyF14, Alt: true}, + "\x1b\x1b[28~": {Type: KeyF15, Alt: true}, + "\x1b\x1b[29~": {Type: KeyF16, Alt: true}, + "\x1b\x1b[31~": {Type: KeyF17, Alt: true}, + "\x1b\x1b[32~": {Type: KeyF18, Alt: true}, + "\x1b\x1b[33~": {Type: KeyF19, Alt: true}, + "\x1b\x1b[34~": {Type: KeyF20, Alt: true}, } // Hex code mappings.