When I’m pressing a key i want to execute an instruction and when I stop pressing the key i want to execute another instruction. (Like the buttons on the android making setOnClickListener -> instruction for example). You can do in Java with the keys?
Sorry for my bad english.
Your question is really hard to understand because you seem to be talking about keys and buttons at the same time. To detect that a button is pressed and then released you will need to override the onTouchEvent() method for the button. For keys/physical buttons on the device there are two methods to override:
update: a more detailed explanation