title: is there a way to get keyboard input on a webpage that listens for it?
body: <p>I'm working on a Chrome extension whose content script injects a bunch of elements in a webpage, including an input element of type text, on specified actions.</p>
  
  <p>the problem is that while on a webpage like Facebook's home page, which listens for keyboard input (e.g., <kbd>P</kbd>), the extension's input element loses focus, which goes to Facebook's "what's on your mind?" section in case of the <kbd>P</kbd>. </p>
  
  <p>I tried getting focus back to the input element programtically, and while that seems to be partially working, as it takes focus back from the "what's on your mind?" section immediately, it still doesn't write the <code>'P'</code> into the text field.</p>
  
  <p>is there anyway to workaround that?</p>
  
  <hr>
  
  <p><strong>update #0:</strong> the code that I tried for regaining focus was as simple as that:</p>
  
  <pre><code>searchBar.onblur = searchBar.focus;
  </code></pre>
  
  <hr>
  
  <p><strong>update #1:</strong> my input element is inside a shadow DOM. apparently the element doesn't lose focus when it's not part of a shadow DOM. any idea on how to get that to work with the shadow DOM?</p>