Skip to content

Add keyboard shortcuts for POS operations#166

Open
abinandabinand21-sudo wants to merge 2 commits intoBrainWise-DEV:developfrom
abinandabinand21-sudo:shortcuts-feature
Open

Add keyboard shortcuts for POS operations#166
abinandabinand21-sudo wants to merge 2 commits intoBrainWise-DEV:developfrom
abinandabinand21-sudo:shortcuts-feature

Conversation

@abinandabinand21-sudo
Copy link

@abinandabinand21-sudo abinandabinand21-sudo commented Feb 26, 2026

Feature: Keyboard Shortcuts for POSNext

Summary

This PR introduces keyboard shortcuts to improve usability and efficiency in POSNext.
It enables a faster, keyboard-driven workflow and reduces reliance on mouse interactions during billing operations.


Features Added

Primary POS Actions

  • Ctrl + O → View Shift
  • Ctrl + D → Draft Invoices
  • Ctrl + I → Invoice History
  • Ctrl + K → Return Invoice
  • Ctrl + P → Close Shift
  • Ctrl + F → Create Customer

Workflow Enhancements

  • Ctrl + B → Focus Item Search / Barcode
  • Ctrl + U → Focus Customer Search
  • Ctrl + Shift + X → Open Promotion & Coupon Management

Implementation Details

  • Added a global keydown event listener
  • Implemented key-to-action mapping for POS operations
  • Dynamically triggers UI actions by matching button text
  • Prevented shortcut execution while typing in input/textarea fields
  • Ensured case-insensitive matching for stability

Benefits

  • Improves cashier efficiency in high-volume environments
  • Reduces dependency on mouse interactions
  • Speeds up billing workflow
  • Provides a more intuitive POS experience

Notes

  • Shortcuts are disabled when typing in input fields
  • Button matching is based on visible UI text
  • No impact on existing functionality

Demo

Screencastfrom2026-02-2617-37-09-ezgif com-video-to-gif-converter

@engahmed1190
Copy link
Contributor

@abinandabinand21-sudo

Thank you very much. This feature has been requested multiple times, and we truly appreciate you taking the initiative to implement it.

We will review it carefully and get back to you shortly with feedback.

Thanks again for the great contribution

Copy link
Contributor

@engahmed1190 engahmed1190 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Keyboard Shortcuts for POS Operations

Thanks for the contribution! Keyboard shortcuts are a great idea for improving cashier efficiency. However, there are several issues that need to be addressed before this can be merged.


1. Fragile button matching via DOM text (Critical)

The entire implementation relies on document.querySelectorAll("button") and matching innerText. This is extremely fragile:

  • Breaks if button text changes, is translated (i18n), or has extra whitespace/icons
  • Breaks if the UI structure changes (e.g., buttons become <a> or <div>)
  • The setTimeout(() => {}, 300) delay is arbitrary — there's no guarantee the button exists after 300ms

2. Placed in main.js instead of a composable/component (Architecture)

Global event listeners in main.js don't integrate with Vue's lifecycle. This should be a Vue composable (useKeyboardShortcuts) or a component so it can:

  • Be properly cleaned up on unmount
  • Access Pinia stores directly instead of DOM scraping
  • Be tested in isolation

3. Conflicts with browser defaults (UX)

Several shortcuts override common browser behavior:

  • Ctrl+D — Bookmark page
  • Ctrl+P — Print page
  • Ctrl+B — Bold text
  • Ctrl+U — View source / underline
  • Ctrl+F — Browser find
  • Ctrl+I — Italic / DevTools

This will frustrate users who expect standard browser behavior.

4. Input guard is incomplete

The check for active.tagName === "INPUT" won't catch all scenarios — Vue components using contenteditable, custom dropdowns with focus, or shadow DOM inputs will be missed. Also, <select> elements are not guarded.

5. Missing newline at EOF

The diff shows \ No newline at end of file.

6. No configurability or discoverability

  • Users can't see available shortcuts anywhere in the UI
  • Shortcuts are hardcoded — no way to customize or disable them

Recommendation

The core problems that need fixing:

  1. DOM text matching should be replaced with direct store actions — call Pinia store methods or emit events instead of finding buttons by text
  2. Move to a composableuseKeyboardShortcuts() that registers/unregisters with Vue lifecycle
  3. Reconsider the key bindings — avoid conflicting with browser defaults; consider using a prefix key or Alt modifier instead of Ctrl

@abinandabinand21-sudo
Copy link
Author

Ok i will work on that and i will update

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.

2 participants