I was trying to make a program that whenever I cause a KeyEvent, the program "presses" the left key, causing me to type backwards in an unorthodox way.
The code shows no errors, but whenever I run it, it runs for a fraction of a second, then terminates.
I can't figure it out, my teacher can't figure it out. HALP
Edit: Yes I know Username, I'm using Robot again, don't mock me :P
Code:
package start;
import java.awt.Robot;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
public class Main {
public static void main(String[] args) throws Exception{
@SuppressWarnings("unused")
abstract class AL implements ActionListener{
public void actionPerformed(KeyEvent e) throws Exception {
Robot r = new Robot();
if(e.isActionKey()){
r.keyPress(KeyEvent.VK_LEFT);
r.keyRelease(KeyEvent.VK_LEFT);
}
}
}
}
}
I can't figure it out, my teacher can't figure it out. HALP
Edit: Yes I know Username, I'm using Robot again, don't mock me :P


Comment