Here you can find the source of getKeyStroke(String s)
static KeyStroke getKeyStroke(String s)
//package com.java2s; //License from project: Apache License import static java.awt.event.InputEvent.CTRL_DOWN_MASK; import static java.awt.event.InputEvent.CTRL_MASK; import java.awt.*; import javax.swing.*; public class Main { static KeyStroke getKeyStroke(String s) { KeyStroke ks = KeyStroke.getKeyStroke(s); if (ks != null && s.matches("(?i).*Ctrl.*")) { return convertShortcutMask(ks, getMenuShortcutKeyMask()); }//from w w w.ja va 2 s .co m return ks; } static KeyStroke convertShortcutMask(KeyStroke ks, int shortcutMask) { final int mod = ks.getModifiers(); if ((mod & (CTRL_DOWN_MASK | CTRL_MASK)) != 0) { final int newmod = mod & ~(CTRL_DOWN_MASK | CTRL_MASK) | shortcutMask; return KeyStroke.getKeyStroke(ks.getKeyCode(), newmod); } return ks; } static int getMenuShortcutKeyMask() { return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } }