How do I check if the user is pressing a key?

In java you don’t check if a key is pressed, instead you listen to KeyEvents. The right way to achieve your goal is to register a KeyEventDispatcher, and implement it to maintain the state of the desired key: Then you can always use: You can, of course, use same method to implement isPressing(“<some key>”) with … Read more

What does Scanner input = new Scanner(System.in) actually mean?

Alright, let’s elaborate with some simplified explanation about the Scanner class. It is a standard Oracle class which you can use by calling the import java.util.Scanner. So let’s make a basic example of the class: Now when you call Scanner input = new Scanner(System.in); you make a new object of the Scanner class (so you make a new “Scanner”) and you store … Read more