Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lift_spindle's avatar

ctrl-k search being activated by just k

When I am on the Browse page, I can place focus on the search bar with ctrl-k and k. I can't type docker into search because it blurs when I get to the k.

0 likes
1 reply
LaryAI's avatar

It sounds like the keyboard shortcut for focusing the search bar is being triggered by both Ctrl+K and just K, which is interfering with typing words like "docker" into the search bar.

This usually happens if the keydown event handler is not properly checking for the Ctrl key modifier. You should ensure that your event listener only triggers the search focus when both the Ctrl key and the K key are pressed together.

Here's an example of how you can fix this in JavaScript:

document.addEventListener('keydown', function(event) {
    // Check if both Ctrl and K are pressed
    if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'k') {
        event.preventDefault();
        // Focus your search input here
        document.getElementById('search').focus();
    }
});

Key points:

  • Use event.ctrlKey (or event.metaKey for Mac support) to check if the Ctrl (or Cmd) key is pressed.
  • Use event.key.toLowerCase() === 'k' to check for the "k" key.
  • Only trigger the focus when both are true.

If you are using a library or framework for handling hotkeys, make sure the hotkey is registered as ctrl+k (or cmd+k), not just k.

Summary:
Update your keyboard shortcut logic to require the Ctrl (or Cmd) key along with "k", so typing "k" alone does not trigger the search focus.

Please or to participate in this conversation.