For now i only need a basic message to be printed as i'll program what i'll actually need later but my problem is:
@Override
public void init(Canvas canvas) {
canvas.addKeyListener(this);
}
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
getStateMachine().setState((byte) 1);
} else if (e.getKeyCode() == KeyEvent.VK_H) {
// Do some other stuff here...
}
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
}
This is what code i have for buttons presses. Enter does a task, but H does not.
package instructionpackagev1;
import java.awt.event.KeyEvent;
public class Instructions {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_H) {
System.out.println("For now, it's a test");
}
}
}
So in other words the basis is, how do i get the letter 'H' to print a line when pressed?