Skip to content

Conversation

@s21v1d9p
Copy link

Summary

Fixes #264957

On macOS, Ctrl+P is a standard emacs-style shortcut for moving to the previous line in text input controls (similar to Ctrl+A for beginning of line, Ctrl+E for end of line, Ctrl+N for next line). Currently, this shortcut is incorrectly suppressed in webviews because the code treats it as the Print command, which is Windows-specific behavior.

Changes

  • Added macOS platform detection using navigator.platform and navigator.userAgent
  • Modified the isPrint() function to return false for Ctrl+P on macOS when metaKey is not pressed
  • On macOS, Cmd+P continues to correctly trigger the print behavior

Testing

  1. Create a VS Code extension with a webview containing a textarea or contenteditable control
  2. Run the extension on macOS
  3. Enter multiple lines of text in the control
  4. Verify Ctrl+P moves the cursor to the previous line
  5. Verify Ctrl+N moves the cursor to the next line
  6. Verify Cmd+P still triggers the print/command palette behavior

On macOS, Ctrl+P is a standard emacs-style shortcut for moving to the
previous line in text input controls. The current implementation
incorrectly suppresses this shortcut by treating it as the Print command,
which is Windows-specific behavior.

This change adds macOS platform detection and modifies the isPrint()
function to only suppress Ctrl+P on non-macOS platforms. On macOS,
Cmd+P continues to correctly trigger the print behavior.

Fixes microsoft#264957
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.

Ctrl-P text navigation shortcut does not work inside webview on macOS

2 participants