Skip to content

Added keyboard CTRL and CMMD keybindings outside of fullscreen mode#1213

Open
tvinhas wants to merge 1 commit into
jetkvm:devfrom
tvinhas:keybindings
Open

Added keyboard CTRL and CMMD keybindings outside of fullscreen mode#1213
tvinhas wants to merge 1 commit into
jetkvm:devfrom
tvinhas:keybindings

Conversation

@tvinhas
Copy link
Copy Markdown
Contributor

@tvinhas tvinhas commented Feb 25, 2026

Summary

  • Locks the keyboard CTRL and COMMAND+C and +V and other keybindings to be used in the remote host when focus is on the screen. Prior to that these would only work in full screen mode.

Checklist

  • Ran make test_e2e locally and passed
  • Linked to issue(s) above by issue number (e.g. Closes #<issue-number>)
  • One problem per PR (no unrelated changes)
  • Lints pass; CI green
  • Tricky parts are commented in code

const [visible, setVisible] = useState(true);

useEffect(() => {
const timer = setTimeout(() => setVisible(false), 8000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

8 seconds seems a little long for a toast message... thoughts?

const isPointerLockPossible =
window.location.protocol === "https:" || window.location.hostname === "localhost";

// macOS detection for Meta key fix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move this to the utils.ts, perhaps?

try {
// @ts-expect-error - keyboard lock is not supported in all browsers
await navigator.keyboard.lock();
console.debug("Keyboard lock acquired");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably can delete this debug and the one on line 172.

I would also make line 162 a console.error

}
}

// When pressing the meta key + another key, the key will never trigger a keyup
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was not specific to mac machines. We need to be careful deleting these work-arounds.

// PiKVM-style fix: When Meta is released on macOS, release all keys to clean up
// stuck companion keys (Chrome doesn't fire their keyup events)
// https://bugs.chromium.org/p/chromium/issues/detail?id=28089
if (isMacClient && (code === "MetaLeft" || code === "MetaRight")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not mac specific. All browsers will act this way. Additionally, we should be careful about releasing all keys given we really shouldn't change the state of keys that are still actually down.

terryrankine added a commit to terryrankine/kvm that referenced this pull request May 7, 2026
- Add keyboardCaptureMode (bool, persisted) and its setter to
  useSettingsStore so the setting survives page reloads
- Add isKeyboardLockActive / setIsKeyboardLockActive to useUiStore
  for runtime tracking of the Keyboard Lock API state
- Refactor useFullscreen: acquire keyboard lock on fullscreen enter
  (from the fullscreenchange event, as required by the API), keep lock
  on exit when keyboardCaptureMode is on, release otherwise; sync
  lock state whenever the setting changes outside fullscreen
- Add "KB Capture" toggle button to BottomBarPC with Active/Limited
  status indicator; shows a success toast on toggle via notifications

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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