How can I prevent Alt key opening Dash Home while my Java app runs in Ubuntu?
Asked Answered
E

1

6

I am learning Slick2D, which perfectly serves my purposes of 2D Java game programming. Unfortunately, I have a problem. I don't think it's Slick2D specific, since I think the same happens with Java Graphics 2D.

In Ubuntu (I'm using Ubuntu 12.04), pressing the Alt key shows the "Dash Home", the same as clicking on the top-left icon in the screen (Windows users, "Dash Home" is sort of "Start" menu).

When my application runs, Alt key still has this behavior and shows the Dash Home. When my game runs in windowed mode, that's not a big deal, since I can go to a paused state. However, when in fullscreen mode, it is a big problem because the system leaves fullscreen and switching between fullscreen and windowed is time consuming and, roughly speaking, ugly.

So, the question is: how can I prevent the Alt keypress to reach the OS, preventing Dash Home to open? In my code I handle keyPresses through the listener provided by Game2D and I don't call any superclass method, so, suposedly the keypress should not be informed to the OS. But... it is.

I am not attaching any code as I don't think this is related to Slick2D, but a general Java issue. Any idea?

Thanks!

Edit: The problem still persists. I have posted the whole source code and binaries of the project here. If it doesn't help to find a solution to this, it may serve as a basic tutorial about Java game programming to other people.

Ethridge answered 18/6, 2014 at 17:49 Comment(0)
A
3

If you are not trying to post this java program to loads of people on Ubuntu computers then you could try this:

Open the System Settings application either by going to Session Indicator in Unity panel, or by searching for System Settings using the HUD.

enter image description here

Then go to Keyboard > Shortcuts > Launchers. You can redefine the HUD key with the Key to show the HUD option. Pressing Backspace will disable the HUD shortcut altogether.

enter image description here

If you set it to Alt manually, the setting distinguishes between the left and right Alt key. So if you want to maintain general behaviour and still use Alt combinations, this may be an alternate solution for you.

And just so you know I got this answer from this website: https://askubuntu.com/questions/122209/how-do-i-modify-or-disable-the-huds-use-of-the-alt-key

I don't know of anyway to temporarily disable the Alt key features but if you don't mind this then I hope this helps

Arvid answered 12/7, 2014 at 7:4 Comment(1)
Thanks! Yet, I would like my program to stop this behavior instead of having to go through Ubuntu System Settings. Your answer will surely be good for me when developping, but in case I want to distribute a game, users should not be forced to change their system settings...Ethridge

© 2022 - 2024 — McMap. All rights reserved.