My code:
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.Scanner;
public class main
{
public static void main(String[] args) throws Exception
{
Thread.sleep(3000);
int x = 66;
int y = (int) 'b';
Robot r = new Robot();
r.keyPress (y);
r.keyRelease(y);
r.keyPress(x);
r.keyRelease(x)
}
}
What has me really confused is, if the variable is a number, like x = 66
, then r.keyPress(x)
will output b - which is correct.
But if I have a variable with the character b and do:
char b = 'b';
int y = (int) b
r.keyPress(y)
It will output 2
.
System.out.print(y)
will output 66. I'm very confused.
I've read the posts, now my question is.. how would I go about: 1. Accept string from user 2. Type out the string with r.keyPress ?