From dc6a4854ceb316627863d1ca825d3a5a1de1bd2c Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 21 Feb 2020 18:50:42 +0000 Subject: [PATCH] Add shortcuts for beginning / end of composer This adds Ctrl/Command+Home/End shortcuts for jumping to the start and end of the composer contents. Fixes https://github.com/vector-im/riot-web/issues/12438 --- src/components/views/rooms/BasicMessageComposer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index a2a01f4444..e478dc590d 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -392,6 +392,20 @@ export default class BasicMessageEditor extends React.Component { } else if (event.key === Key.ENTER && (event.shiftKey || (IS_MAC && event.altKey))) { this._insertText("\n"); handled = true; + // move selection to start of composer + } else if (modKey && event.key === Key.HOME) { + setSelection(this._editorRef, model, { + index: 0, + offset: 0, + }); + handled = true; + // move selection to end of composer + } else if (modKey && event.key === Key.END) { + setSelection(this._editorRef, model, { + index: model.parts.length - 1, + offset: model.parts[model.parts.length - 1].text.length, + }); + handled = true; // autocomplete or enter to send below shouldn't have any modifier keys pressed. } else { const metaOrAltPressed = event.metaKey || event.altKey;