Last active
August 15, 2020 21:05
-
-
Save SuperJedi224/7ac234b03471baf5f778eada93121f4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The following class is hereby released into the public domain under a CC0 public domain dedication. | |
To the greatest extent permitted by law, I hereby fully, permanently, irrevocably, and unconditionally | |
waive all copyright protection that may apply to this class. | |
*/ | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import java.util.*; | |
public final class ControlHandler implements KeyListener{ | |
private static ControlHandler i; | |
private ControlHandler(){}; | |
public static ControlHandler getInstance(){ | |
if(i==null)i=new ControlHandler(); | |
return i; | |
} | |
private static final Map<Integer,Boolean>keys=new HashMap<>(); | |
@Override | |
public void keyPressed(KeyEvent arg0) { | |
keys.put(arg0.getKeyCode(),true); | |
} | |
@Override | |
public void keyReleased(KeyEvent arg0) { | |
keys.put(arg0.getKeyCode(),false); | |
} | |
@Override | |
public void keyTyped(KeyEvent arg0) {} | |
public static boolean isKeyDown(int code){ | |
return keys.getOrDefault(code,false); | |
} | |
public static boolean isKeyDown(char key){ | |
return isKeyDown(KeyEvent.getExtendedKeyCodeForChar(key)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SuperJedi224 what does G,3,1,3, G,2,2,3, and G,2,1,4 equal to in your Graham's Sequence? How do you make the 4th entry go up? On your website almost infinite. I'm having trouble understanding the 4th entry.