Skip to content

Conversation

@arjav1528
Copy link

PR Description

This PR adds a keyboard shortcut feature that allows users to send API requests using Cmd+Enter (macOS) or Ctrl+Enter (Windows/Linux) instead of clicking the send button. This enhancement significantly improves the workflow for keyboard-centric users who prefer to navigate and interact with the application using keyboard shortcuts.

Changes Made

  • Added keyboard shortcut support in RequestEditor widget (desktop view)

    • Implemented CallbackShortcuts to listen for Cmd+Enter (macOS) or Ctrl+Enter (other platforms)
    • Wrapped the editor pane with Focus widget to ensure keyboard events are properly captured
    • The shortcut triggers the same sendRequest() function used by the send button
  • Added keyboard shortcut support in RequestResponsePage widget (mobile/tablet view)

    • Applied the same keyboard shortcut functionality for consistency across all views
    • Ensures the feature works seamlessly in both desktop and mobile layouts

Technical Implementation

  • Uses Flutter's CallbackShortcuts widget to register keyboard bindings
  • Platform-aware shortcut detection: SingleActivator with meta: true for macOS and control: true for other platforms
  • Integrates with existing Riverpod state management to trigger request sending
  • Maintains focus management through Focus widget with autofocus: true for immediate keyboard responsiveness

User Experience

Users can now:

  1. Focus on any part of the request editor
  2. Press Cmd+Enter (macOS) or Ctrl+Enter (Windows/Linux) to instantly send the request
  3. Continue working without interrupting their keyboard workflow

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes
  • No, and this is why: The keyboard shortcut functionality integrates with existing widget tests. The implementation uses standard Flutter keyboard handling mechanisms (CallbackShortcuts) which are well-tested by the framework. Manual testing confirms the feature works correctly on both macOS and other platforms.

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pressing command enter should send request on mac(maybe ctrl + enter on linux/windows)

1 participant