# Device buttons

**URL:** <https://forum.juce.com/t/device-buttons/13174>\
**Category:** Android\
**Created:** [July 14, 2014, 8:58pm UTC](https://forum.juce.com/t/device-buttons/13174 "2014-07-14T20:58:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dang](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@dang](https://forum.juce.com/u/dang)\
**Post date:** [July 14, 2014, 8:58pm UTC](https://forum.juce.com/t/device-buttons/13174/1 "2014-07-14T20:58:55Z")

</div>

Hi. I'm really liking Juce so far; nice clean API, great docs. Awesome!

&nbsp;

Is there any way to have Juce respond to Android device buttons - e.g.&nbsp;Back, Menu? I've searched a few times, but haven't found anything so far. Possibly I'm just using the wrong keywords :)

&nbsp;

Any help greatly appreciated!

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [July 15, 2014, 8:05am UTC](https://forum.juce.com/t/device-buttons/13174/2 "2014-07-15T08:05:22Z")

</div>

I'm totally new to Android dev, but perhaps KeyPressed() might return somthing useful? Otherwise you'll probably need to do this on the JAVA side.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 15, 2014, 8:36am UTC](https://forum.juce.com/t/device-buttons/13174/3 "2014-07-15T08:36:17Z")

</div>

This has been on my to-do-list.. I was rather hoping that someone using android would give me a helpful snippet that points me in the right direction... :)

---

<div class="post-metadata">

**Author:** ![dang](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@dang](https://forum.juce.com/u/dang)\
**Post date:** [July 15, 2014, 11:14am UTC](https://forum.juce.com/t/device-buttons/13174/4 "2014-07-15T11:14:48Z")

</div>

Thanks guys.

&nbsp;

I'll try Rory's suggestion, and see if I get anything from keyPressed. That would certainly be a sensible way for the device to report it, but I suspect Android might not be that sensible :) Otherwise I'll take a look around the Android docs and post here again if I find anything useful. If it does involve Java, my motivation to get it working may diminish somewhat ;)

&nbsp;

Thanks again

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [July 15, 2014, 11:18am UTC](https://forum.juce.com/t/device-buttons/13174/5 "2014-07-15T11:18:58Z")

</div>

I hear you. I'm currently pirouetting around JAVA obstacles like Nijinsky. I fear I've run out of stage however. Crash, thump, wallop.&nbsp;

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [July 15, 2014, 2:21pm UTC](https://forum.juce.com/t/device-buttons/13174/6 "2014-07-15T14:21:05Z")

</div>

Btw, have you looked at this:

http://www.juce.com/forum/topic/android-dpi-bug?page=1

Might be of some help to you?

---

<div class="post-metadata">

**Author:** ![dang](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@dang](https://forum.juce.com/u/dang)\
**Post date:** [July 21, 2014, 4:25pm UTC](https://forum.juce.com/t/device-buttons/13174/7 "2014-07-21T16:25:58Z")

</div>

Fantastic, thanks Rory. I'll take a look.

---

<div class="post-metadata">

**Author:** ![nikolaiaudios](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nikolaiaudios](https://forum.juce.com/u/nikolaiaudios)\
**Post date:** [July 15, 2015, 2:06pm UTC](https://forum.juce.com/t/device-buttons/13174/8 "2015-07-15T14:06:01Z")

</div>

How is the device buttons comming along? It's been a year so it might be done already for what I know.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 15, 2015, 2:13pm UTC](https://forum.juce.com/t/device-buttons/13174/9 "2015-07-15T14:13:52Z")

</div>

Don't think we've got anything new, but Android is a big priority for us now, so I'll make sure this is in our backlog!

---

<div class="post-metadata">

**Author:** ![loopfine](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/loopfine/32/141_2.png) [@loopfine](https://forum.juce.com/u/loopfine)\
**Post date:** [July 15, 2015, 3:56pm UTC](https://forum.juce.com/t/device-buttons/13174/10 "2015-07-15T15:56:45Z")

</div>

For support the back button of Android, my nasty solution is:

```
bool ComponentForSomething::keyPressed (const KeyPress& key)
{
    if (key == KeyPress::escapeKey)
    {
        // ... make it disvisible, show pervious component,
        // deliver the escapeKey to parent component or something else

        return true;
    }
    return Component::keyPressed (key);
}
```

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [July 15, 2015, 4:29pm UTC](https://forum.juce.com/t/device-buttons/13174/11 "2015-07-15T16:29:06Z")

</div>

I've been wondering how to get the back button working for Android... will try your escape key method, thanks

---

<div class="post-metadata">

**Author:** ![nikolaiaudios](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nikolaiaudios](https://forum.juce.com/u/nikolaiaudios)\
**Post date:** [July 16, 2015, 6:17am UTC](https://forum.juce.com/t/device-buttons/13174/12 "2015-07-16T06:17:53Z")

</div>

Is it that easy? Thank you, the back button is kind of important.

---

<div class="post-metadata">

**Author:** ![nikolaiaudios](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nikolaiaudios](https://forum.juce.com/u/nikolaiaudios)\
**Post date:** [July 16, 2015, 6:18am UTC](https://forum.juce.com/t/device-buttons/13174/13 "2015-07-16T06:18:44Z")

</div>

Glad to hear about the Android future, thanks

---

<div class="post-metadata">

**Author:** ![timur](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timur/32/541_2.png) [@timur](https://forum.juce.com/u/timur)\
**Post date:** [July 16, 2015, 9:42am UTC](https://forum.juce.com/t/device-buttons/13174/14 "2015-07-16T09:42:48Z")

</div>

As Jules already said, this is in our backlog and we will implement it as soon as we have time.

---

<div class="post-metadata">

**Author:** ![DustVoice](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dustvoice/32/9222_2.png) [@DustVoice](https://forum.juce.com/u/DustVoice)\
**Post date:** [March 16, 2019, 8:22pm UTC](https://forum.juce.com/t/device-buttons/13174/15 "2019-03-16T20:22:37Z")

</div>

How is the current status on this?

In our app it is a **huge** issue unfortunately that if you type text into a text editor and press the back button that the keyboard reappears, as the text editor natively doesn’t lose focus. This wouldn’t be a problem at all if I could unfocus everything on pres of the back button. Unfortunately the back button is not handled by the keyPressed event in any way!

---

<div class="post-metadata">

**Author:** ![ZioGuido](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zioguido/32/6975_2.png) [@ZioGuido](https://forum.juce.com/u/ZioGuido)\
**Post date:** [April 29, 2020, 6:09pm UTC](https://forum.juce.com/t/device-buttons/13174/16 "2020-04-29T18:09:00Z")

</div>

Still nothing, I guess…

---

<div class="post-metadata">

**Author:** ![ZioGuido](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zioguido/32/6975_2.png) [@ZioGuido](https://forum.juce.com/u/ZioGuido)\
**Post date:** [April 29, 2020, 6:10pm UTC](https://forum.juce.com/t/device-buttons/13174/17 "2020-04-29T18:10:25Z")

</div>

> [@loopfine](#):
>
> For support the back button of Android, my nasty solution is

I know this was 5 years ago, but I’m trying your method now and it doesn’t catch the back button on my Galaxy S10.

---

<div class="post-metadata">

**Author:** ![ZioGuido](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zioguido/32/6975_2.png) [@ZioGuido](https://forum.juce.com/u/ZioGuido)\
**Post date:** [April 29, 2020, 9:43pm UTC](https://forum.juce.com/t/device-buttons/13174/18 "2020-04-29T21:43:12Z")

</div>

Oh wow! Just found out that the back button is managed in the [ApplicationBase class](https://docs.juce.com/master/classJUCEApplicationBase.html)

```
virtual bool backButtonPressed()
```

---

<div class="post-metadata">

**Author:** ![Benicz](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Benicz](https://forum.juce.com/u/Benicz)\
**Post date:** [October 19, 2021, 12:39am UTC](https://forum.juce.com/t/device-buttons/13174/19 "2021-10-19T00:39:30Z")

</div>

Another one on this bumpy road here:  
I’d like to intercept volume rocker events.  
While nothing(!) happens on android, it (sort of) works on windows (surface pro 7):  
keyPressed() gets called, but the keyCode is always 0, while it should be 174(0xAE) or 175(0xAF).

I’m not into keycodes, unicode and implementation layers, but could it be a reason there is no Keypress::volumeUpKey implemented (yet)?  
doKeyDown() (juce\_win32\_Windowing.cpp, line 3017) however runs into the switche’s default and tries translating it into unicode, but ToUnicode() obviously returns “0”  
There are definitions for play, stop etc. in juce\_keyPress.h though, and volume keys are listed at least in winUser.h…

Puhh, much info, hope it doesn’t confuse…  
Maybe somebody can point me to the right direction?  
Thanks!!

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [October 19, 2021, 1:36pm UTC](https://forum.juce.com/t/device-buttons/13174/20 "2021-10-19T13:36:13Z")

</div>

I have an FR for just this. Voting on it would be better than digging up old threads! 😃

> [@FR: Add support for more multimedia keys](https://forum.juce.com/t/fr-add-support-for-more-multimedia-keys/41811):
>
> I’ve been trying to use JUCE for a general media app and found myself stuck when trying to configure an assortment of input shortcuts. This is particularly off-putting because I need to use a remote control for the app on an embedded device. To summarise the missing media key input functionality: pause (Note that this is different than the play/pause key) stop volume up volume down mute record channel up channel down find/search help For Windows: VK\_PAUSE + APPCOMMAND\_MEDIA\_PAUSE VK\_MEDIA…

[Next page](https://forum.juce.com/t/device-buttons/13174.md?page=2)
