Search code examples
javascriptwindowsgoogle-chromekeyboard-eventsbrowserstack

browserstack ctrl+enter keyboard event not registering in chrome or IE


I'm testing a feature on Browserstack and am unsure if it's really broken on Windows or if Browserstack is just not getting my keyboard events properly.

I'm trying to detect when the user presses ctrl+enter. I have a code snippet below that works fine in Chrome on my MacBook. However, when I use Browserstack to run it in Windows 10 with Chrome 87 (Latest), it does not register the correct keyboard event.

Steps to Reproduce

  1. On a MacBook, go to www.browserstack.com
  2. Start a live session with this post as the url: https://stackoverflow.com/questions/65113392
  3. Choose Windows 10 Chrome 87 (Latest)
  4. Click the Run the code snippet button below inside Browserstack
  5. Click on the input field
  6. Press ctrl+enter

Expected behavior: I see "key: Enter, ctrlKey: true"

Observed behavior: I see "key: Control, ctrlKey: true"

const input = document.getElementById('input')
const output = document.getElementById('output')
input.addEventListener('keydown', (e) => {
  output.innerText = `key: ${e.key}, ctrlKey: ${e.ctrlKey}`
})
<input type="text" id="input" />
<div id="output"></div>


Solution

  • I spoke to Browerstack's customer service. They were able to confirm it's a bug in Browserstack. I think it has to do with the way they switch cmd and ctrl keys. In any case, it sounds like they aren't prioritizing the bug.

    If you're working on an app where you need to press ctrl+enter (e.g. to submit a comment so users can use the enter key for creating newlines), your best bet for testing is https://www.lambdatest.com. I checked all the other major competitors and LambdaTest is the only one that has free live testing, although you do need to register for an account unlike with Browserstack. LambdaTest doesn't have this bug so I was able to test the feature there just fine.