Java Code Examples for java.awt.event.KeyEvent#VK_COMMA

The following examples show how to use java.awt.event.KeyEvent#VK_COMMA . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RLangInputHandler.java    From Processing.R with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean handleTyped(KeyEvent event) {
  char c = event.getKeyChar();

  if ((event.getModifiers() & InputEvent.CTRL_MASK) != 0) {
    // on linux, ctrl-comma (prefs) being passed through to the editor
    if (c == KeyEvent.VK_COMMA) {
      event.consume();
      return true;
    }
    // https://github.com/processing/processing/issues/3847
    if (c == KeyEvent.VK_SPACE) {
      event.consume();
      return true;
    }
  }
  return false;
}
 
Example 2
Source File: NewEntryFrameUtil.java    From Zettelkasten with GNU General Public License v3.0 6 votes vote down vote up
public static void checkSpelling(int key, javax.swing.JTextArea ta, Settings settingsObj, AutoKorrektur spellObj) {
    if (KeyEvent.VK_SPACE == key || KeyEvent.VK_PERIOD == key || KeyEvent.VK_COMMA == key || KeyEvent.VK_BRACELEFT == key || KeyEvent.VK_ENTER == key || KeyEvent.VK_OPEN_BRACKET == key || KeyEvent.VK_COLON == key || KeyEvent.VK_QUOTE == key) {
        if (ta != null) {
            try {
                int caret = ta.getCaretPosition();
                String text = ta.getText();
                if (settingsObj.getSpellCorrect()) {
                    if (caret > 2) {
                        int start = text.lastIndexOf(" ", caret - 2);
                        int start2 = text.lastIndexOf(System.lineSeparator(), caret - 2);
                        if (start2 > start) {
                            start = start2;
                        }
                        String wrong = text.substring(start + 1, caret - 1);
                        String correct = spellObj.getCorrectSpelling(wrong);
                        if (correct != null) {
                            StringBuilder sb = new StringBuilder(text);
                            sb.replace(start + 1, caret - 1, correct);
                            ta.setText(sb.toString());
                            caret = caret - wrong.length() + correct.length();
                            ta.setCaretPosition(caret);
                        }
                    }
                }
                if (KeyEvent.VK_QUOTE == key) {
                    // TODO Anfrührungszeichen ersetzen
                    // <ALT>+0132 bzw.
                    // <ALT>+0147 typographische Anführungszeichen oben / unten hin.
                }
            } catch (IndexOutOfBoundsException | IllegalArgumentException ex) {
            }
        }
    }
}
 
Example 3
Source File: XTable.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean editCellAt(int i, int i1, EventObject e) {
    Boolean flag = super.editCellAt(i, i1, e);
    if (flag) {
        if (e instanceof KeyEvent) {
            int code = ((KeyEvent) e).getKeyCode();
            if (code < KeyEvent.VK_DELETE
                    && code >= KeyEvent.VK_COMMA) {
                getEditorComponent().requestFocusInWindow();
            }
        }
    }
    return flag;
}
 
Example 4
Source File: Visualization.java    From whyline with MIT License 4 votes vote down vote up
public boolean handleKeyPressed(KeyEvent event) {

		updateMeta();
		
		switch(event.getKeyCode()) {

		case KeyEvent.VK_T :
			whylineUI.getActions().showHideThreads.actionPerformed(null);
			return true;

		case KeyEvent.VK_B :
			
			EventView view = getSelectedEventView();
			if(view != null) {
				Instruction inst = trace.getInstruction(view.getEventID());
				if(inst != null) {
					Line line = inst.getLine();
					if(line != null) {
						boolean wasNew = whylineUI.getPersistentState().addRelevantLine(line);
						if(wasNew)
							return true;
					}
				}
			}
			Toolkit.getDefaultToolkit().beep();
			return true;

		case KeyEvent.VK_ESCAPE :
			getWhylineUI().getActions().collapseBlock.execute();
			return true;

		case KeyEvent.VK_ENTER :
			getWhylineUI().getActions().addToExplanation.execute();
			return true;

		case KeyEvent.VK_COMMA :

			if(!showPreviousOrNextEventInThreadOrMethod(true, true))
				Toolkit.getDefaultToolkit().beep();
			return true;

		case KeyEvent.VK_PERIOD :

			if(!showPreviousOrNextEventInThreadOrMethod(false, true))
				Toolkit.getDefaultToolkit().beep();
			return true;

		case KeyEvent.VK_LEFT :
			
			if(isMetaDown) {
				if(!showPreviousOrNextEventInThreadOrMethod(true, false))
					Toolkit.getDefaultToolkit().beep();
			}
			else
				getWhylineUI().getActions().goToPreviousEvent.execute();
			return true;

		case KeyEvent.VK_RIGHT :
			
			if(isMetaDown) {
				if(!showPreviousOrNextEventInThreadOrMethod(false, false))
					Toolkit.getDefaultToolkit().beep();
			}
			else
				getWhylineUI().getActions().goToNextEvent.execute();
			return true;

		case KeyEvent.VK_UP :
			getWhylineUI().getActions().goToPreviousBlock.execute();
			return true;

		case KeyEvent.VK_DOWN : 
			getWhylineUI().getActions().goToNextBlock.execute();
			return true;

		}
		
		if(Character.isLetterOrDigit(event.getKeyChar()))
			return goToDataDependency(event.getKeyChar(), !isMetaDown);

		return false;
		
	}
 
Example 5
Source File: PreferencesCommand.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
private PreferencesCommand() {
    super(I18n.Text("Preferences…"), CMD_PREFERENCES, KeyEvent.VK_COMMA);
}
 
Example 6
Source File: ActionUtils.java    From workcraft with MIT License 4 votes vote down vote up
public static String getKeyString(int keyCode) {
    // Letters and numbers
    if (((keyCode >= KeyEvent.VK_0) && (keyCode <= KeyEvent.VK_9))
            || ((keyCode >= KeyEvent.VK_A) && (keyCode <= KeyEvent.VK_Z))) {
        return String.valueOf((char) keyCode);
    }
    switch (keyCode) {
    // Navigation keys
    case KeyEvent.VK_LEFT: return "Left";
    case KeyEvent.VK_UP: return "Up";
    case KeyEvent.VK_RIGHT: return "Right";
    case KeyEvent.VK_DOWN: return "Down";
    // Extra navigation keys
    case KeyEvent.VK_INSERT: return "Insert";
    case KeyEvent.VK_DELETE: return "Delete";
    case KeyEvent.VK_END: return "End";
    case KeyEvent.VK_HOME: return "Home";
    case KeyEvent.VK_PAGE_UP: return "PgUp";
    case KeyEvent.VK_PAGE_DOWN: return "PgDn";
    // Function keys
    case KeyEvent.VK_F1: return "F1";
    case KeyEvent.VK_F2: return "F2";
    case KeyEvent.VK_F3: return "F3";
    case KeyEvent.VK_F4: return "F4";
    case KeyEvent.VK_F5: return "F5";
    case KeyEvent.VK_F6: return "F6";
    case KeyEvent.VK_F7: return "F7";
    case KeyEvent.VK_F8: return "F8";
    case KeyEvent.VK_F9: return "F9";
    case KeyEvent.VK_F10: return "F10";
    case KeyEvent.VK_F11: return "F11";
    case KeyEvent.VK_F12: return "F12";
    // Symbols
    case KeyEvent.VK_EXCLAMATION_MARK: return "!";
    case KeyEvent.VK_QUOTEDBL: return "\"";
    case KeyEvent.VK_EURO_SIGN: return "€";
    case KeyEvent.VK_DOLLAR: return "$";
    case KeyEvent.VK_CIRCUMFLEX: return "^";
    case KeyEvent.VK_AMPERSAND: return "&";
    case KeyEvent.VK_ASTERISK: return "*";
    case KeyEvent.VK_UNDERSCORE: return "_";
    case KeyEvent.VK_MINUS: return "-";
    case KeyEvent.VK_PLUS: return "+";
    case KeyEvent.VK_EQUALS: return "=";
    case KeyEvent.VK_AT: return "@";
    case KeyEvent.VK_NUMBER_SIGN: return "#";
    case KeyEvent.VK_COLON: return ":";
    case KeyEvent.VK_SEMICOLON: return ";";
    case KeyEvent.VK_COMMA: return ",";
    case KeyEvent.VK_PERIOD: return ".";
    case KeyEvent.VK_SLASH: return "/";
    case KeyEvent.VK_BACK_SLASH: return "\\";
    case KeyEvent.VK_DEAD_TILDE: return "~";
    // Parenthesis and brackets
    case KeyEvent.VK_LEFT_PARENTHESIS: return "(";
    case KeyEvent.VK_RIGHT_PARENTHESIS: return ")";
    case KeyEvent.VK_OPEN_BRACKET: return "[";
    case KeyEvent.VK_CLOSE_BRACKET: return "]";
    case KeyEvent.VK_BRACELEFT: return "{";
    case KeyEvent.VK_BRACERIGHT: return "}";
    case KeyEvent.VK_LESS: return "<";
    case KeyEvent.VK_GREATER: return ">";
    // Formatting keys
    case KeyEvent.VK_SPACE: return "Space";
    case KeyEvent.VK_TAB: return "Tab";
    case KeyEvent.VK_ENTER: return "Enter";
    case KeyEvent.VK_BACK_SPACE: return "Backspace";
    case KeyEvent.VK_ESCAPE: return "Esc";
    }
    return "0x" + Integer.toString(keyCode, 16);
}
 
Example 7
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getNonAlphaCharWithoutShift(int code) {
	switch (code) {
	case KeyEvent.VK_BACK_QUOTE:
		return "`";
	case KeyEvent.VK_1:
		return "1";
	case KeyEvent.VK_2:
		return "2";
	case KeyEvent.VK_3:
		return "3";
	case KeyEvent.VK_4:
		return "4";
	case KeyEvent.VK_5:
		return "5";
	case KeyEvent.VK_6:
		return "6";
	case KeyEvent.VK_7:
		return "7";
	case KeyEvent.VK_8:
		return "8";
	case KeyEvent.VK_9:
		return "9";
	case KeyEvent.VK_0:
		return "0";
	case KeyEvent.VK_MINUS:
		return "-";
	case KeyEvent.VK_EQUALS:
		return "=";
	case KeyEvent.VK_OPEN_BRACKET:
		return "[";
	case KeyEvent.VK_CLOSE_BRACKET:
		return "]";
	case KeyEvent.VK_SEMICOLON:
		return ";";
	case KeyEvent.VK_QUOTE:
		return "'";
	case KeyEvent.VK_BACK_SLASH:
		return "\\";
	case KeyEvent.VK_COMMA:
		return ",";
	case KeyEvent.VK_PERIOD:
		return ".";
	case KeyEvent.VK_SLASH:
		return "/";
	case KeyEvent.VK_TAB:
		return "\t";
	case KeyEvent.VK_ENTER:
		return "\n";
	case KeyEvent.VK_SPACE:
		return " ";
	default:
		return "";
	}
}
 
Example 8
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getNonAlphaCharWithShift(int code) {
	switch (code) {
	case KeyEvent.VK_BACK_QUOTE:
		return "~";
	case KeyEvent.VK_1:
		return "!";
	case KeyEvent.VK_2:
		return "@";
	case KeyEvent.VK_3:
		return "#";
	case KeyEvent.VK_4:
		return "$";
	case KeyEvent.VK_5:
		return "%";
	case KeyEvent.VK_6:
		return "^";
	case KeyEvent.VK_7:
		return "&";
	case KeyEvent.VK_8:
		return "*";
	case KeyEvent.VK_9:
		return "(";
	case KeyEvent.VK_0:
		return ")";
	case KeyEvent.VK_MINUS:
		return "_";
	case KeyEvent.VK_EQUALS:
		return "+";
	case KeyEvent.VK_OPEN_BRACKET:
		return "{";
	case KeyEvent.VK_CLOSE_BRACKET:
		return "}";
	case KeyEvent.VK_SEMICOLON:
		return ":";
	case KeyEvent.VK_QUOTE:
		return "\"";
	case KeyEvent.VK_BACK_SLASH:
		return "|";
	case KeyEvent.VK_COMMA:
		return "<";
	case KeyEvent.VK_PERIOD:
		return ">";
	case KeyEvent.VK_SLASH:
		return "?";
	case KeyEvent.VK_TAB:
		return "\t";
	case KeyEvent.VK_ENTER:
		return "\n";
	case KeyEvent.VK_SPACE:
		return " ";
	default:
		return "";
	}
}
 
Example 9
Source File: InputHandler.java    From JavaGame with GNU Affero General Public License v3.0 4 votes vote down vote up
private void toggleKey(int keyCode, boolean isPressed) {
	if (!isIgnoreInput()) {
		if (keyCode == KeyEvent.VK_Z && isAzertyCountry || keyCode == KeyEvent.VK_W && !isAzertyCountry
				|| keyCode == KeyEvent.VK_UP) {
			up.toggle(isPressed);
		}

		if (keyCode == KeyEvent.VK_Q && isAzertyCountry || keyCode == KeyEvent.VK_A && !isAzertyCountry
				|| keyCode == KeyEvent.VK_LEFT) {
			left.toggle(isPressed);
		}

		if (keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_DOWN) {
			down.toggle(isPressed);
		}

		if (keyCode == KeyEvent.VK_D || keyCode == KeyEvent.VK_RIGHT) {
			right.toggle(isPressed);
		}
	}
	if (isIgnoreInput()) {
		up.toggle(false);
		down.toggle(false);
		left.toggle(false);
		right.toggle(false);
	}

	if (keyCode == KeyEvent.VK_M) {
		if(!toggleMusic){
			Game.getBackgroundMusic().play();
			print.print("Playing Music", PrintTypes.MUSIC);
			toggleMusic = true;
		}
	}

	if (keyCode == KeyEvent.VK_COMMA) {
		Game.getBackgroundMusic().stop();
		if(toggleMusic)
			print.print("Stopping Music", PrintTypes.MUSIC);
			toggleMusic = false;
	}


	if (keyCode == KeyEvent.VK_W && isAzertyCountry || keyCode == KeyEvent.VK_Z && !isAzertyCountry) {
		// if (map == 0){
		// Game.getGame().setMap("/levels/water_level.png");
		// map++;
		// } else{
		// Game.getGame().setMap("/levels/custom_level.png");
		// map--;
		// }
		if (Game.getMap() == 2) {
			if (Game.isNpc()) {
				Game.setNpc(false);
			}
			Game.setChangeLevel(true);
		}
	}
	if (keyCode == KeyEvent.VK_N) {
		if (Game.getPlayer().isMoving()) {
			setIgnoreInput(true);
			int n = popup.Warn("Stop moving before spawning dummy AI");
			if (n == 0) {
				setIgnoreInput(false);
			}
			return;
		}
		if (!Game.isNpc()) {
			Game.setNpc(true);
			Game.npcSpawn();
			print.print("Dummy has been spawned", PrintTypes.GAME);
		}
	}
	if (keyCode == KeyEvent.VK_K) {
		if (Game.isNpc()) {
			Game.setNpc(false);
			Game.npcKill();
			print.print("Dummy has been removed", PrintTypes.GAME);
		}
	}

	if (keyCode == KeyEvent.VK_A && isAzertyCountry || keyCode == KeyEvent.VK_Q && !isAzertyCountry)
		this.quitGame();

	if (keyCode == KeyEvent.VK_BACK_QUOTE) {
		if (!Game.isClosing() && !Game.isDevMode()) {
			Game.setDevMode(true);
			new Thread(new SleepThread());
		}
	}
}
 
Example 10
Source File: Commander.java    From Scripts with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(final KeyEvent ke) {

	final int key = ke.getKeyCode();
	final Object source = ke.getSource();
	final boolean meta = (ke.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
	final boolean metaShift = meta && ke.isShiftDown();

	// Close if Esc, Ctrl+W or Cmd+W
	if (key == KeyEvent.VK_ESCAPE || (key == KeyEvent.VK_W && meta)) {
		quit();

		// Trigger Menu accelerators
	} else if (metaShift) {
		if (key == KeyEvent.VK_C) // Enter/Exit Console
			toggleConsoleMode();
		else if (key == KeyEvent.VK_G) // Go To...
			changeDirectory("");
		else if (!isConsoleMode() && key == KeyEvent.VK_R) // Reveal Path
			Utils.revealFile(path);

	} else if (meta) {

		if (key == KeyEvent.VK_L) {
			prompt.requestFocusInWindow();
			prompt.selectAll();
		} else if (key == KeyEvent.VK_B) {
			activateTable();
		} else if (key == KeyEvent.VK_COMMA) {
			showOptionsDialog();
		} else if (key == KeyEvent.VK_S) {
			saveQuery();
		} else if (!isConsoleMode() && key == KeyEvent.VK_D) {
			addBookmark();
		} else if (!isConsoleMode() && key == KeyEvent.VK_P) {
			printList();
		} else if (!isConsoleMode() && key == KeyEvent.VK_R) {
			resetFileList("Contents reloaded...");
		}

	} else if (source == prompt) {

		// Up or down arrows pressed in prompt: Move the focus to list
		if (key == KeyEvent.VK_UP || key == KeyEvent.VK_DOWN) {
			activateTable();
		}

	} else if (source == table) {

		// Focus in list and left arrow key: move up in directory hierarchy
		if (key == KeyEvent.VK_LEFT) {
			selectParentDirectory(path);
			setSelectedItem(table.getSelectedRow());

			// Focus in list and right arrow key: List sub-directory
		} else if (key == KeyEvent.VK_RIGHT) {
			setSelectedItem(table.getSelectedRow());
			if (isFolder(selectedItem))
				selectSubDirectory(selectedItem);

			// Focus in list and enter: Open selected item
		} else if (key == KeyEvent.VK_ENTER) {
			ke.consume();
			setSelectedItem(table.getSelectedRow());
			openItem(selectedItem);

			// Focus in list and backspace: Switch focus back to prompt
		} else if (key == KeyEvent.VK_BACK_SPACE) {
			prompt.requestFocusInWindow();
			prompt.selectAll();

			// Focus in list and up/down arrow key: Loop through list
		} else if (key == KeyEvent.VK_UP) {
			if (table.getSelectedRow() == 0)
				table.setRowSelectionInterval(tableModel.getRowCount() - 1, tableModel.getRowCount() - 1);
		} else if (key == KeyEvent.VK_DOWN) {
			if (table.getSelectedRow() == tableModel.getRowCount() - 1)
				table.setRowSelectionInterval(0, 0);
		}

	}

}