KeyListener - not quite sure how to set it up

class xAudioProcessorEditor  : public AudioProcessorEditor, public SliderListener, public Timer, public KeyListener

	bool keyPressed (const KeyPress &key, Component *originatingComponent);

xAudioProcessorEditor::xAudioProcessorEditor (xAudioProcessorEditor* ownerFilter)

bool x::keyPressed (const KeyPress &key, Component *originatingComponent)
...//breakpoint set here

can anyone see anything wrong? all i want to eventually do is update the text field of a label to what the user is typing. i’m not doing anything differently to others ive found after a search and yet keyPressed is not running.


this is really holding me up now, can anyone shed any light? i’m looking through the demo projects now which handle keyboard events fine but i cant see how its all being registered.


Hard to tell what you’re doing wrong from that snippet, but you’ve probably just attached your listener to a component that doesn’t have the keyboard focus, so isn’t getting any events.


i dont know if it’s relevant but I just checked LRESULT peerWindowProc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) in juce_win32_Windowing.cpp and the function never receives a WM_CHAR message when i click a key, even after bringing the plugin window to focus and clicking on it. but it does in the Juce Demo. Should I be registering the keyboard as a broadcaster somewhere?


Ah, if it’s a plugin, then you might not be getting any keypresses at all - some hosts eat them before the plugin gets them. Search the forum for various threads bemoaning this kind of thing…


ah right, that explained it. i was using savihost as the plugin host. just switched to nuendo and its all working now. thank you Jules.