本文整理匯總了Java中java.awt.event.KeyEvent.VK_S屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.VK_S屬性的具體用法?Java KeyEvent.VK_S怎麽用?Java KeyEvent.VK_S使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_S屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: keyPressed
/**
* Wir überschreiben was beim drücken einer Taste passiert.
* hat den nachteil das ohne unser zutun sonst nix mehr passiert
* z.B. ESC oder ähnliches.
* @param e
*/
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_S) {
setKey_down(true);
}
if (e.getKeyCode() == KeyEvent.VK_W) {
setKey_up(true);
}
if (e.getKeyCode() == KeyEvent.VK_D) {
setKey_right(true);
}
if (e.getKeyCode() == KeyEvent.VK_A) {
setKey_left(true);
}
if(e.getKeyCode() == KeyEvent.VK_ESCAPE){
System.exit(0);
}
}
示例2: toggleKey
protected void toggleKey(int keyCode, boolean isPressed) {
switch (keyCode) {
case KeyEvent.VK_LEFT:
humanAction[Player.KEY_LEFT] = isPressed;
break;
case KeyEvent.VK_RIGHT:
humanAction[Player.KEY_RIGHT] = isPressed;
break;
case KeyEvent.VK_DOWN:
humanAction[Player.KEY_DOWN] = isPressed;
break;
case KeyEvent.VK_S:
humanAction[Player.KEY_JUMP] = isPressed;
break;
case KeyEvent.VK_A:
humanAction[Player.KEY_SPEED] = isPressed;
break;
case KeyEvent.VK_SPACE:
humanAction[Player.KEY_CARRYDROP] = isPressed;
break;
}
}
示例3: keyReleased
public boolean keyReleased(KeyReleasedEvent e) {
switch(e.getKey()) {
case KeyEvent.VK_W:
up = false;
return true;
case KeyEvent.VK_SPACE:
up = false;
return true;
case KeyEvent.VK_A:
left = false;
return true;
case KeyEvent.VK_S:
return true;
case KeyEvent.VK_D:
right = false;
return true;
}
return false;
}
示例4: keyPressed
public boolean keyPressed(KeyPressedEvent e) {
switch(e.getKey()) {
case KeyEvent.VK_W:
up = true;
return true;
case KeyEvent.VK_SPACE:
up = true;
return true;
case KeyEvent.VK_A:
left = true;
return true;
case KeyEvent.VK_S:
return true;
case KeyEvent.VK_D:
right = true;
return true;
}
return false;
}
示例5: keyReleased
private void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
switch (key) {
case KeyEvent.VK_W: // up
System.out.println("W pressed.");
_board.handleUp("W" );
break;
case KeyEvent.VK_S: // down
System.out.println("S pressed.");
_board.handleDown("S");
break;
case KeyEvent.VK_A: // left
System.out.println("A pressed.");
_board.handleLeft("A");
break;
case KeyEvent.VK_D: // right
System.out.println("D pressed.");
_board.handleRight("D");
break;
default:
}
}
示例6: ModifierRobotKeyTest
public ModifierRobotKeyTest() throws Exception {
modifierKeys = new int[4];
modifierKeys[0] = KeyEvent.VK_SHIFT;
modifierKeys[1] = KeyEvent.VK_CONTROL;
modifierKeys[2] = KeyEvent.VK_ALT;
modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;
inputMasks = new int[4];
inputMasks[0] = InputEvent.SHIFT_MASK;
inputMasks[1] = InputEvent.CTRL_MASK;
inputMasks[2] = InputEvent.ALT_MASK;
inputMasks[3] = InputEvent.ALT_GRAPH_MASK;
modifierStatus = new boolean[modifierKeys.length];
textKeys = new int[2];
textKeys[0] = KeyEvent.VK_A;
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("solaris") || os.contains("sunos"))
textKeys[1] = KeyEvent.VK_S;
else if (os.contains("os x"))
textKeys[1] = KeyEvent.VK_K;
else
textKeys[1] = KeyEvent.VK_I;
textStatus = new boolean[textKeys.length];
EventQueue.invokeAndWait( () -> { initializeGUI(); });
}
示例7: ModifierRobotEnhancedKeyTest
public ModifierRobotEnhancedKeyTest() throws Exception {
modifierKeys = new int[4];
modifierKeys[0] = KeyEvent.VK_SHIFT;
modifierKeys[1] = KeyEvent.VK_CONTROL;
modifierKeys[2] = KeyEvent.VK_ALT;
modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;
inputMasks = new int[4];
inputMasks[0] = InputEvent.SHIFT_MASK;
inputMasks[1] = InputEvent.CTRL_MASK;
inputMasks[2] = InputEvent.ALT_MASK;
inputMasks[3] = InputEvent.ALT_GRAPH_MASK;
modifierStatus = new boolean[modifierKeys.length];
textKeys = new int[6];
textKeys[0] = KeyEvent.VK_A;
textKeys[1] = KeyEvent.VK_S;
textKeys[2] = KeyEvent.VK_DELETE;
textKeys[3] = KeyEvent.VK_HOME;
textKeys[4] = KeyEvent.VK_F12;
textKeys[5] = KeyEvent.VK_LEFT;
textStatus = new boolean[textKeys.length];
EventQueue.invokeAndWait( () -> { initializeGUI(); });
}
示例8: update
public void update() {
up = keys[KeyEvent.VK_UP] || keys[KeyEvent.VK_W];
down = keys[KeyEvent.VK_DOWN] || keys[KeyEvent.VK_S];
left = keys[KeyEvent.VK_LEFT] || keys[KeyEvent.VK_A];
right = keys[KeyEvent.VK_RIGHT] || keys[KeyEvent.VK_D];
dash = keys[KeyEvent.VK_CONTROL];
}
示例9: handleNormalKey
/**
* Handle the keyboard events.
*
* @param key the key code
*/
private void handleNormalKey(int key) {
switch (key) {
case KeyEvent.VK_DELETE:
deleteObject();
break;
case KeyEvent.VK_A:
// move the box to the left
moveObject(-1, 0);
break;
case KeyEvent.VK_D:
// move the box to the right
moveObject(1, 0);
break;
case KeyEvent.VK_W:
// move the box up
moveObject(0, -1);
break;
case KeyEvent.VK_S:
// move the box down
moveObject(0, 1);
break;
default:
// do nothing
break;
}
}
示例10: keyReleased
@Override
public void keyReleased(KeyEvent e){
if(DynamicBeat.game == null){
return;
}
if(e.getKeyCode()==KeyEvent.VK_S){
DynamicBeat.game.releaseS();
}
else if(e.getKeyCode()==KeyEvent.VK_D){
DynamicBeat.game.releaseD();
}
else if(e.getKeyCode()==KeyEvent.VK_F){
DynamicBeat.game.releaseF();
}
else if(e.getKeyCode()==KeyEvent.VK_SPACE){
DynamicBeat.game.releaseSpace();
}
else if(e.getKeyCode()==KeyEvent.VK_J){
DynamicBeat.game.releaseJ();
}
else if(e.getKeyCode()==KeyEvent.VK_K){
DynamicBeat.game.releaseK();
}
else if(e.getKeyCode()==KeyEvent.VK_L){
DynamicBeat.game.releaseL();
}
}
示例11: keyPressed
public void keyPressed(KeyEvent key) {
if(key.isControlDown()) {
if(key.getKeyCode() == KeyEvent.VK_R) {
recording = !recording;
return;
}
if(key.getKeyCode() == KeyEvent.VK_S) {
screenshot = true;
return;
}
}
Keys.keySet(key.getKeyCode(), true);
}
示例12: keyCodeToInput
private Inputs keyCodeToInput(int keyCode, int keyLocation) {
switch (keyCode) {
case KeyEvent.VK_UP:
return Inputs.RightDPadUp;
case KeyEvent.VK_DOWN:
return Inputs.RightDPadDown;
case KeyEvent.VK_LEFT:
return Inputs.RightDPadLeft;
case KeyEvent.VK_RIGHT:
return Inputs.RightDPadRight;
case KeyEvent.VK_I:
return Inputs.RightDPadUp;
case KeyEvent.VK_K:
return Inputs.RightDPadDown;
case KeyEvent.VK_J:
return Inputs.RightDPadLeft;
case KeyEvent.VK_L:
return Inputs.RightDPadRight;
case KeyEvent.VK_W:
return Inputs.LeftDPadUp;
case KeyEvent.VK_S:
return Inputs.LeftDPadDown;
case KeyEvent.VK_A:
return Inputs.LeftDPadLeft;
case KeyEvent.VK_D:
return Inputs.LeftDPadRight;
case KeyEvent.VK_SPACE:
return Inputs.Select;
case KeyEvent.VK_ENTER:
return Inputs.Start;
case KeyEvent.VK_F:
return Inputs.A;
case KeyEvent.VK_H:
return Inputs.B;
case KeyEvent.VK_E:
return Inputs.L;
case KeyEvent.VK_U:
return Inputs.R;
case KeyEvent.VK_CONTROL:
if (keyLocation == KeyEvent.KEY_LOCATION_RIGHT) {
return Inputs.A;
}
break;
case KeyEvent.VK_NUMPAD0:
return Inputs.B;
case KeyEvent.VK_B:
return Inputs.LowBattery;
}
return null;
}
示例13: handleCtrlKey
/**
* Handling of the keyboard events when Control key is pressed.
*
* @param key the key code
*/
private void handleCtrlKey(int key) {
switch (key) {
case KeyEvent.VK_PLUS:
log.info("Key pressed: Ctrl NumPad+ = Zoom in");
break;
case KeyEvent.VK_MINUS:
log.info("Key pressed: Ctrl NumPad- = Zoom out");
break;
case KeyEvent.VK_A:
// decrease left
gc.changeSizeSelection(1, 0, 0, 0);
break;
case KeyEvent.VK_W:
// decrease top
gc.changeSizeSelection(0, 1, 0, 0);
break;
case KeyEvent.VK_D:
// decrease right
gc.changeSizeSelection(0, 0, -1, 0);
break;
case KeyEvent.VK_S:
// decrease bottom
gc.changeSizeSelection(0, 0, 0, -1);
break;
default:
// do nothing
break;
}
}
示例14: keyPressed
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_S) {
EditorTopComponent.this.overviewButton.setSelected(true);
EditorTopComponent.this.overviewAction.setState(true);
}
}
示例15: keyReleased
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_S) {
EditorTopComponent.this.overviewButton.setSelected(false);
EditorTopComponent.this.overviewAction.setState(false);
}
}