hey mauricio,
you can use like this. just add this kind of function in your class.
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_I) {
//do something when I is pressed
return true;
} else if (keyCode == KeyEvent.KEYCODE_O) {
//do something when O is pressed
return true;
} else if (keyCode == KeyEvent.KEYCODE_S) {
//do something when S is pressed
return true;
} else if (keyCode == KeyEvent.KEYCODE_M) {
//do something when M is pressed
return true;
}
return false;
}
best of luck !! :)
regards,
wahib
On 3/21/10, Mauricio <[email protected]> wrote:
> I understand onKeyDown should give me the key that was pressed, but
> how to do that? I mean, if I do something like
>
>
> public boolean onKeyDown(int keyCode, KeyEvent event)
> {
> switch (keyCode)
> {
> case 97 : // Letter A
> DoSomething();
> break;
> default :
> // Do nothing
> break;
> }
> // Indicate you took care of this event
> return true;
>
> }
>
> Would it detect when I press the letter A on the keyboard?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>
> To unsubscribe from this group, send email to
> android-beginners+unsubscribegooglegroups.com or reply to this email with
> the words "REMOVE ME" as the subject.
>
--
Wahib-ul-haq
3rd year Communications Engineering Student,
NUST, Pakistan.
Microsoft Student Partner
follow me on twitter @wahibhaq
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
To unsubscribe from this group, send email to
android-beginners+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.