Skip to content

Instantly share code, notes, and snippets.

@ronnyworm
Created March 25, 2017 14:07
Show Gist options
  • Save ronnyworm/c55499c510b1d0241b410f7d6baf5f53 to your computer and use it in GitHub Desktop.
Save ronnyworm/c55499c510b1d0241b410f7d6baf5f53 to your computer and use it in GitHub Desktop.
class GearsKeyAdapter extends KeyAdapter {
public void keyPressed(KeyEvent e) {
int kc = e.getKeyCode();
if(KeyEvent.VK_LEFT == kc) {
view_roty -= 1;
} else if(KeyEvent.VK_RIGHT == kc) {
view_roty += 1;
} else if(KeyEvent.VK_UP == kc) {
view_rotx -= 1;
} else if(KeyEvent.VK_DOWN == kc) {
view_rotx += 1;
}
}
}
KeyListener gearsKeys = new GearsKeyAdapter();
getContentPane().addKeyListener(gearsKeys);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment