Add keyboard shortcuts for POS operations#166
Add keyboard shortcuts for POS operations#166abinandabinand21-sudo wants to merge 2 commits intoBrainWise-DEV:developfrom
Conversation
|
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 |
engahmed1190
left a comment
There was a problem hiding this comment.
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:
- DOM text matching should be replaced with direct store actions — call Pinia store methods or emit events instead of finding buttons by text
- Move to a composable —
useKeyboardShortcuts()that registers/unregisters with Vue lifecycle - Reconsider the key bindings — avoid conflicting with browser defaults; consider using a prefix key or
Altmodifier instead ofCtrl
|
Ok i will work on that and i will update |
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
Workflow Enhancements
Implementation Details
keydownevent listenerBenefits
Notes
Demo