本文整理匯總了Java中java.awt.event.KeyEvent.VK_INSERT屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.VK_INSERT屬性的具體用法?Java KeyEvent.VK_INSERT怎麽用?Java KeyEvent.VK_INSERT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_INSERT屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toggle
/**
* This method is used to turn keyboard key presses into actions
*/
private void toggle(KeyEvent ke, boolean pressed) {
if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD8 ) up.toggle( pressed ); //press keypad 8, moves up
if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD2 ) down.toggle( pressed ); //press keypad 2, moves down
if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD4 ) left.toggle( pressed ); //press keypad 4, moves left
if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD6 ) right.toggle( pressed ); //press keypad 6, moves right
if ( ke.getKeyCode( ) == KeyEvent.VK_W ) up.toggle( pressed ); //press W, moves up
if ( ke.getKeyCode( ) == KeyEvent.VK_S ) down.toggle( pressed ); //press S, moves down
if ( ke.getKeyCode( ) == KeyEvent.VK_A ) left.toggle( pressed ); //press A, moves left
if ( ke.getKeyCode( ) == KeyEvent.VK_D ) right.toggle( pressed ); //press D, moves right
if ( ke.getKeyCode( ) == KeyEvent.VK_UP ) up.toggle( pressed ); //press up arrow, moves up
if ( ke.getKeyCode( ) == KeyEvent.VK_DOWN ) down.toggle( pressed ); //press down arrow, moves down
if ( ke.getKeyCode( ) == KeyEvent.VK_LEFT ) left.toggle( pressed ); //press left arrow, moves left
if ( ke.getKeyCode( ) == KeyEvent.VK_RIGHT ) right.toggle( pressed ); //press right arrow, moves right
// if ( ke.getKeyCode( ) == KeyEvent.VK_TAB ) menu.toggle( pressed ); //press Tab, menu toggled
// if ( ke.getKeyCode( ) == KeyEvent.VK_ALT ) menu.toggle( pressed ); //press Alt, menu toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_ALT_GRAPH ) menu.toggle( pressed ); //press Alt-Graph, menu toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_SPACE ) attack.toggle( pressed ); //press space, attack toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_CONTROL ) attack.toggle( pressed ); //press Ctrl, attack toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD0 ) attack.toggle( pressed ); //press keypad 0, attack toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_INSERT ) attack.toggle( pressed ); //press Insert, attack toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_ENTER ) menu.toggle( pressed ); //press Enter, attack toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_X ) menu.toggle( pressed ); //press X, menu toggled
if ( ke.getKeyCode( ) == KeyEvent.VK_C ) attack.toggle( pressed ); // press C, attack toggled
}
示例2: keyPressed
/**
* {@inheritDoc}
*/
@Override
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
//
// 6 key editing group
//
case KeyEvent.VK_INSERT:
sendChars(e, "\033[L"); // NOI18N
break;
case KeyEvent.VK_HOME:
sendChars(e, "\033[H"); // NOI18N
break;
//
// Arrow keys
//
case KeyEvent.VK_UP:
sendChars(e, "\033[A"); // NOI18N
break;
case KeyEvent.VK_DOWN:
sendChars(e, "\033[B"); // NOI18N
break;
case KeyEvent.VK_RIGHT:
sendChars(e, "\033[C"); // NOI18N
break;
case KeyEvent.VK_LEFT:
sendChars(e, "\033[D"); // NOI18N
break;
}
}
示例3: onKeyPressed
final void onKeyPressed(final int keyCode) {
if (keyCode == KeyEvent.VK_DELETE) {
controller.actionRemove();
} else if (keyCode == KeyEvent.VK_INSERT) {
controller.actionAddDirectory();
}
}
示例4: keyPressed
@Override
public void keyPressed(KeyEvent e) {
int ign = InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK;
if ((e.getModifiersEx() & ign) != 0)
return;
switch (e.getKeyCode()) {
case KeyEvent.VK_LEFT:
case KeyEvent.VK_KP_LEFT:
if (pos > 0)
--pos;
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_KP_RIGHT:
if (pos < curText.length())
++pos;
break;
case KeyEvent.VK_HOME:
pos = 0;
break;
case KeyEvent.VK_END:
pos = curText.length();
break;
case KeyEvent.VK_ESCAPE:
case KeyEvent.VK_CANCEL:
cancelEditing();
break;
case KeyEvent.VK_CLEAR:
curText = "";
pos = 0;
break;
case KeyEvent.VK_ENTER:
stopEditing();
break;
case KeyEvent.VK_BACK_SPACE:
if (pos > 0) {
curText = curText.substring(0, pos - 1) + curText.substring(pos);
--pos;
field.setText(curText);
}
break;
case KeyEvent.VK_DELETE:
if (pos < curText.length()) {
curText = curText.substring(0, pos) + curText.substring(pos + 1);
field.setText(curText);
}
break;
case KeyEvent.VK_INSERT:
case KeyEvent.VK_COPY:
case KeyEvent.VK_CUT:
case KeyEvent.VK_PASTE:
// TODO: enhance label editing
break;
default:
; // ignore
}
}