Skip to content

Commit 829cc39

Browse files
Added: Allow users to disable hardware keyboard shortcuts
The user can add `disable-hardware-keyboard-shortcuts=true` entry to `termux.properties` file to disable hardware keyboard shortcuts. The default value is `false`. Running `termux-reload-settings` command will also update the behaviour instantaneously if changed. Note that for `ctrl+alt+p` to work, you need to unset `shortcut.rename-session = ctrl + n`. https://wiki.termux.com/wiki/Terminal_Settings Closes #1825
1 parent 16c56a9 commit 829cc39

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ public boolean onKeyDown(int keyCode, KeyEvent e, TerminalSession currentSession
216216
if (keyCode == KeyEvent.KEYCODE_ENTER && !currentSession.isRunning()) {
217217
mTermuxTerminalSessionClient.removeFinishedSession(currentSession);
218218
return true;
219-
} else if (e.isCtrlPressed() && e.isAltPressed()) {
219+
} else if (!mActivity.getProperties().areHardwareKeyboardShortcutsDisabled() &&
220+
e.isCtrlPressed() && e.isAltPressed()) {
220221
// Get the unmodified code point:
221222
int unicodeChar = e.getUnicodeChar(0);
222223

termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxPropertyConstants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public final class TermuxPropertyConstants {
7272

7373
/* boolean */
7474

75+
/** Defines the key for whether hardware keyboard shortcuts are enabled. */
76+
public static final String KEY_DISABLE_HARDWARE_KEYBOARD_SHORTCUTS = "disable-hardware-keyboard-shortcuts"; // Default: "disable-hardware-keyboard-shortcuts"
77+
78+
7579
/** Defines the key for whether a toast will be shown when user changes the terminal session */
7680
public static final String KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST = "disable-terminal-session-change-toast"; // Default: "disable-terminal-session-change-toast"
7781

@@ -295,6 +299,7 @@ public final class TermuxPropertyConstants {
295299
* */
296300
public static final Set<String> TERMUX_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
297301
/* boolean */
302+
KEY_DISABLE_HARDWARE_KEYBOARD_SHORTCUTS,
298303
KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST,
299304
KEY_ENFORCE_CHAR_BASED_INPUT,
300305
KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP,
@@ -335,6 +340,7 @@ public final class TermuxPropertyConstants {
335340
* default: false
336341
* */
337342
public static final Set<String> TERMUX_DEFAULT_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST = new HashSet<>(Arrays.asList(
343+
KEY_DISABLE_HARDWARE_KEYBOARD_SHORTCUTS,
338344
KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST,
339345
KEY_ENFORCE_CHAR_BASED_INPUT,
340346
KEY_HIDE_SOFT_KEYBOARD_ON_STARTUP,

termux-shared/src/main/java/com/termux/shared/settings/properties/TermuxSharedProperties.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ public static String getVolumeKeysBehaviourInternalPropertyValueFromValue(String
460460

461461

462462

463+
public boolean areHardwareKeyboardShortcutsDisabled() {
464+
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST, true);
465+
}
466+
463467
public boolean areTerminalSessionChangeToastsDisabled() {
464468
return (boolean) getInternalPropertyValue(TermuxPropertyConstants.KEY_DISABLE_TERMINAL_SESSION_CHANGE_TOAST, true);
465469
}

0 commit comments

Comments
 (0)