当我在mac上运行程序时,我想使用"command"键而不是"control"键。
我有一个列表与点击侦听器;今天在mac上,要选择多个项目,我使用"control"+点击。我想使用"command" + click。
有办法用java改变键或键盘吗?
Then with:
if (os.startsWith("Mac OS X"){}
我只能在mac上使用这个键。
谢谢。
如何在Mac中使用Command-c/Command-v快捷方式复制/粘贴文本?-用于使用命令键。
http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/-使用这个来获取操作系统
使用System.getProperties(os.name)
获取操作系统的名称
-
可以检测当前操作系统
public class MachineUtil { private static final String os = System.getProperty("os.name").toLowerCase(new Locale("")); /** * Returns true if the operating system is a form of Linux. */ public static boolean isLinux() { return os.indexOf("linux") >= 0; } /** * Returns true if the operating system is a form of Windows. */ public static boolean isWindows() { return os.indexOf("win") >= 0; } /** * Returns true if the operating system is a form of Mac OS. */ public static boolean isMac() { return os.indexOf("mac") >= 0; }}