# Application hosting VST/AU plugins crashes at keyboard input when plugin window is in focus

**URL:** <https://forum.juce.com/t/application-hosting-vst-au-plugins-crashes-at-keyboard-input-when-plugin-window-is-in-focus/57002>\
**Category:** General JUCE discussion\
**Created:** [July 12, 2023, 1:31pm UTC](https://forum.juce.com/t/application-hosting-vst-au-plugins-crashes-at-keyboard-input-when-plugin-window-is-in-focus/57002 "2023-07-12T13:31:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kraku](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kraku](https://forum.juce.com/u/Kraku)\
**Post date:** [July 12, 2023, 1:31pm UTC](https://forum.juce.com/t/application-hosting-vst-au-plugins-crashes-at-keyboard-input-when-plugin-window-is-in-focus/57002/1 "2023-07-12T13:31:11Z")

</div>

I’m writing an application which hosts VST/AU plugins.

When I open up a juce::DocumentWindow which contains the plugin GUI inside it, and press keyboard key, I get a failed assertion. The assertion happens on line 2204 of file juce\_mac\_NSViewComponentPeer.mm:

jassertfalse; // The system should not attempt to insert text when there is no active TextInputTarget

How should I handle the plugin windows so that if they want keyboard input (for example for naming presets, etc.) that window can use the keyboard input. But otherwise the keyboard presses go to the main application, so it can react to starting / stopping the song when spacebar is pressed, etc.

---

<div class="post-metadata">

**Author:** ![Kraku](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kraku](https://forum.juce.com/u/Kraku)\
**Post date:** [July 13, 2023, 8:41am UTC](https://forum.juce.com/t/application-hosting-vst-au-plugins-crashes-at-keyboard-input-when-plugin-window-is-in-focus/57002/2 "2023-07-13T08:41:28Z")

</div>

It seems that when I add an extra juce::KeyListener to the DocumentWindow, the application doesn’t crash anymore.

I made my MainComponent a juce::KeyListener and returned “true” from:  
bool keyPressed(const KeyPress& key, Component\* originatingComponent).

That seems to prevent the crashes.  
I’m not sure if some extra magic is required to make the plugins handle their own keyboard input properly, if they have some use for keyboard functions.

---

<div class="post-metadata">

**Author:** ![Kraku](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kraku](https://forum.juce.com/u/Kraku)\
**Post date:** [July 13, 2023, 9:00am UTC](https://forum.juce.com/t/application-hosting-vst-au-plugins-crashes-at-keyboard-input-when-plugin-window-is-in-focus/57002/3 "2023-07-13T09:00:47Z")

</div>

My issue solved itself when I added the MainComponent as keyboard listener, overriding both keyPressed() and keyStateChanged() from juce::KeyListener class.
