# Spurious button click sent when pressing escape in ComboBox

**URL:** <https://forum.juce.com/t/spurious-button-click-sent-when-pressing-escape-in-combobox/64841>\
**Category:** General JUCE discussion\
**Created:** [January 9, 2025, 12:53pm UTC](https://forum.juce.com/t/spurious-button-click-sent-when-pressing-escape-in-combobox/64841 "2025-01-09T12:53:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jpo/32/503_2.png) [@jpo](https://forum.juce.com/u/jpo)\
**Post date:** [January 9, 2025, 12:53pm UTC](https://forum.juce.com/t/spurious-button-click-sent-when-pressing-escape-in-combobox/64841/1 "2025-01-09T12:53:39Z")

</div>

How to reproduce: in WidgetsDemo.h, MiscPage, add a

`TextButton button;`

and initialise it in the MiscPage() constructor:

```auto
button.addShortcut(KeyPress{KeyPress::returnKey});
button.onClick = [this]() { textEditor1.setText("THIS IS UNEXPECTED"); };
addAndMakeVisible(button);

```

Then lanch DemoRunner. In that demo, click in the combo box, so that its text is selected in edit mode. Press ‘Enter’, the ComboBox has the focus, press ‘Enter’ again, the combo box is now showing its PopupMenu. Press ‘Escape’ to exit the menu, and the button ‘onClick’ method is called.

I think this is caused by the way Button keyboard shortcuts are handled. It incorrectly assumes that the Return key has been released, when the escape key is released…

(test performed on macos, with latest develop).
