utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
27.05k stars 1.34k forks source link

ignore cmd in VM when pressing CMD + tab to switch window #5411

Open ashleycox opened 1 year ago

ashleycox commented 1 year ago

Running Windows virtual machines in UTM. I've noticed that many keystrokes and key commands are still passed to the VM even if the input isn't captured. This presents an annoying issue when you press cmd + tab to switch to another MacOS window, as the cmd key triggers the windows start menu every time. Could there be an option to stop modifier keys being passed unless the input is captured, or ideally stop any key being passed unless the input is captured?

freebrowser1 commented 1 year ago

Indeed this is a feature missing which VirtualBox and VMWare Fusion do have.

I get around it by installing Sharpkeys in the Windows VM to swap the cmd (called 'Windows' key) and the ctrl key. In Ubuntu I did the same by:

# cmd / alt swap in Ubuntu: https://cdmana.com/2022/03/202203271213306191.html
sudo nano /usr/share/X11/xkb/keycodes/evdev
        <LALT> = 64;
        // <LCTL> = 37;
        <LCTL> = 133;
        <SPCE> = 65;
        <RCTL> = 105;
        <RALT> = 108;
        // Microsoft keyboard extra keys
        <LWIN> = 37;
        // <LWIN> = 133;
        <RWIN> = 134;
        <COMP> = 135;

In both cases I use the Option key as 'Alt/cmd' key in Windows (and Ubuntu) so Option+Tab switches apps within the VM and Cmd+Tab within the host macOS, regardless whether you are inside or outside the VM. And copy/paste works with Cmd-C / V inside the VM as well. In a terminal inside the VM I have to use the Option as Ctrl key, e.g. Option+C = abortion instead of Ctrl+C.

I never understood why Apple does not allow swapping the Ctrl and Cmd keys. There is another third party option: Karabiner (pqrs.org) which allows this per app in macOS so you can swap these keys only in UTM.

peruginiandrea commented 1 year ago

I never understood why Apple does not allow swapping the Ctrl and Cmd keys.

Maybe I misunderstood what you meant by swapping ctrl and cmd, but System Settings -> Keyboard -> Keyboard Shortcuts… -> Modifier Keys lets you do that.

(By the way, I like having ctrl+A and ctrl+E for navigating text, instead of the Windows way)