Arrow keys work without Fn outside Text Entry

; . , / are arrows on their own unless the foreground App is editing
text (App::textEntryActive); Fn + those keys are arrows everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-02 13:59:49 +02:00
co-authored by Claude Opus 5.5
parent 51698a8011
commit 5fd351c45e
10 changed files with 82 additions and 6 deletions
+3
View File
@@ -22,6 +22,9 @@ class App {
return false;
}
// True while the App is editing text: the arrow keys then type ; . , / and need Fn to move.
virtual bool textEntryActive() const { return false; }
// Called every main-loop pass while in the foreground (e.g. to refresh live values).
virtual void update(uint32_t nowMs) { (void)nowMs; }
+10 -3
View File
@@ -87,14 +87,21 @@ void KeyMapper::onChar(char c, const RawKeys& keys, std::vector<KeyEvent>& out)
return;
}
if (keys.fn) {
if (keys.fn || !textEntry_) {
switch (c) {
case ';': out.push_back(KeyEvent::of(Key::Up)); return;
case '.': out.push_back(KeyEvent::of(Key::Down)); return;
case ',': out.push_back(KeyEvent::of(Key::Left)); return;
case '/': out.push_back(KeyEvent::of(Key::Right)); return;
case '`': out.push_back(KeyEvent::of(Key::Home)); return;
default: return; // other Fn combos are unassigned
case '`':
if (keys.fn) {
out.push_back(KeyEvent::of(Key::Home));
return;
}
break;
default:
if (keys.fn) return; // other Fn combos are unassigned
break;
}
}
if (c == '`') {
+8 -2
View File
@@ -22,12 +22,17 @@ struct RawKeys {
};
// Turns keyboard state changes into logical KeyEvents: only newly pressed keys produce events;
// Fn + ; . , / are arrows; ` is Back and Fn + ` is Home; the Compose Key (opt) followed by an
// accent and a letter types the accented letter (opt ' e -> é).
// Fn + ; . , / are arrows, and so are ; . , / alone when no text is being entered; ` is Back and
// Fn + ` is Home; the Compose Key (opt) followed by an accent and a letter types the accented
// letter (opt ' e -> é).
class KeyMapper {
public:
std::vector<KeyEvent> update(const RawKeys& keys);
// Whether the foreground App is editing text (default). Outside text entry, the arrow keys
// don't need Fn.
void setTextEntry(bool active) { textEntry_ = active; }
// 0 when idle, '*' when opt was pressed, or the accent character waiting for its letter.
char pendingCompose() const { return compose_; }
@@ -36,6 +41,7 @@ class KeyMapper {
RawKeys previous_;
char compose_ = 0;
bool textEntry_ = true;
};
} // namespace roro