1

I would like use the "command" key instead of "control" key when i'm running my program on mac.

I have got a list with a click listener; today on mac, to select multiple items I use "control" + click. I would like use "command" + click.

Is there any way to change the key or change the keyboard with java ?

Then with :

if (os.startsWith("Mac OS X"){}

I could use the key only on mac.

Thanks.

4

3 回答 3

0

How to use Command-c/Command-v shortcut in Mac to copy/paste text? - Use this for using the command key.

http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/ - Use this for getting the operating system.

于 2013-06-03T15:13:52.627 回答
0

use System.getProperties(os.name) to get the name of your Operating System

于 2013-06-03T15:19:44.983 回答
0
  • You can detect the current os.

    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;
            }}
    
于 2013-06-03T15:48:40.687 回答