Java tutorial
//package com.java2s; //License from project: Apache License import java.awt.*; import java.awt.event.*; public class Main { private static int keyStrokeModMac(String keyStrokeStr) { keyStrokeStr = keyStrokeStr.toLowerCase(); int mod = 0; if (keyStrokeStr.contains("ctrl") || keyStrokeStr.contains("control")) { mod = mod | InputEvent.CTRL_MASK; } if (keyStrokeStr.contains("alt")) { mod = mod | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (keyStrokeStr.contains("meta")) { mod = mod | InputEvent.ALT_MASK; } return mod; } }