Git Product home page Git Product logo

Comments (1)

escherlies avatar escherlies commented on June 19, 2024

Technical Details

Issue Analysis: Further investigation into the application's codebase revealed that the behavior is due to the isCtrlOrAlt function not recognizing the Option (also known as Alt on non-Mac systems) key on macOS. The current implementation of the function is as follows:

// ts/hooks/useKeyboardShortcuts.tsx:22
function isCtrlOrAlt(ev: KeyboardEvent): boolean {
  const { altKey, ctrlKey } = ev;
  const controlKey = get(window, 'platform') === 'darwin' && ctrlKey;
  const theAltKey = get(window, 'platform') !== 'darwin' && altKey;
  return controlKey || theAltKey;
}

This code checks for the ctrlKey when the platform is darwin (macOS), which does not account for the macOS convention of using the Option key for functionalities often associated with the Alt key on other platforms.

Proposed Code Modification: To address this issue, it is recommended to modify the isCtrlOrAlt function to recognize both the ctrlKey and altKey on macOS, thereby aligning with the expected behavior of the Option key by macOS users. A corrected version of the function is proposed below:

// ts/hooks/useKeyboardShortcuts.tsx:22
function isCtrlOrAlt(ev: KeyboardEvent): boolean {
  const { altKey, ctrlKey } = ev;
  // For macOS, check both ctrlKey and altKey, as users might expect the Option key to function similarly to Alt
  const isMac = get(window, 'platform') === 'darwin';
  const controlOrAltOnMac = isMac && (ctrlKey || altKey);
  const altKeyOnOthers = !isMac && altKey;

  return controlOrAltOnMac || altKeyOnOthers;
}

By implementing this change, the application should correctly recognize the Option + ArrowUp keyboard shortcut as intended for navigating between chats on macOS, without inadvertently triggering the edit functionality of the last message.

from signal-desktop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.