Using the hardware keyboard to simulate button press on Android
<p>it is difficult to test a game with the mouse pointer on android buttons. I would like to control those buttons with the hardware keyboard. Actually I don't want to control the buttons itself but I want to control the behaviour the buttons would also do. For example I have 4 buttons in the android application with "arrow up, down, left, right". I'd like to use the arrow buttons of my hardware keyboard to control the same. How can I do that? Actually the question is, where can I set the Listener? I tried something in my activity. I set this listener to the application button:</p>

<pre><code>        button.setOnKeyListener(new OnKeyListener() {           
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
                //scroll down
            return true;
        }
    });
</code></pre>

<p>The behaviour is the following:
I can't scroll down with my hardware keyboard but with the hardware keyboard I can select the android buttons (they will be highlighted when I move on any button). After I selected the button with the Listener I can't select any other button anymore but then the Listener comes into force. Now I can scroll down with the hardware keyboard arrow down button. I would like to achieve this behaviour without selecting any button. So I thought about setting the listener to the layout container or any other layout but this has no effect. Is there any other approach to achieve this?</p>
