Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxKeys CONTROL vs. WINDOWS vs. CTRL vs. COMMAND (vs. META?) #2983

Open
ninjamuffin99 opened this issue Dec 13, 2023 · 1 comment
Open

FlxKeys CONTROL vs. WINDOWS vs. CTRL vs. COMMAND (vs. META?) #2983

ninjamuffin99 opened this issue Dec 13, 2023 · 1 comment

Comments

@ninjamuffin99
Copy link
Member

On Mac, there is SEEMINGLY no key for the COMMAND key... after some investigation, it seems to be the same keycode as the FlxKeys.WINDOWS keycode, which is 15.

Digging a bit further, the OpenFL class KeyboardEvent has some interesting bools available

       /**
		Indicates whether the Command key is active (`true`) or inactive
		(`false`). Supported for Mac OS only. On Mac OS, the `commandKey`
		property has the same value as the `ctrlKey` property.
	**/
	public var commandKey:Bool;

	/**
		Indicates whether the Control key is active (`true`) or inactive
		(`false`). On Windows and Linux, this is also true when the Ctrl key
		is active.
	**/
	public var controlKey:Bool;

	/**
		On Windows and Linux, indicates whether the Ctrl key is active
		(`true`) or inactive(`false`); On Mac OS, indicates
		whether either the Ctrl key or the Command key is active.
	**/
	public var ctrlKey:Bool;

I'm wondering if there's a nice way to incorporate cleanly a way to get COMMAND off Mac, without some fussyness from trying to just use FlxKeys.WINDOWS.

Thoughts/ideas

  1. Renaming FlxKeys.WINDOWS to something like FlxKeys.META, and having a proper comment around it describing that it's Windows key on Windows, and the COMMAND key on Mac
  2. Incorporating something around KeyboardEvent.ctrlKey, in cases where you might want to use CTRL on Windows, AND have it sorta "auto" use COMMAND on Mac. Something like having both FlxKey.CONTROL for when you want CTRL on Win, and CONTROL on mac, AND THEN having FlxKey.CTRL for when you want to have CTRL on Win, and then uses COMMAND on mac.
  3. Having a FlxKey.COMMAND, that only is true/properly resolves on Mac, and when compiled to windows, doesn't return?
@Geokureli
Copy link
Member

Geokureli commented Dec 13, 2023

I recently experienced this when fuxing with the debug tools

we could add var COMMAND = 15; and var CTRL = 17; with ease, with no need to only expose it when targeting the correct OS. In fact we would need to expose every key for every OS on html, anyway so let's just make something that works on the fly if needed.

I think for having an OS aware keys we would need to have a different suffix or prefix to denote them, like call them

var CTRL_KEY = 
    #if windows 17 // CTRL
    #elseif mac 15 // COMMAND
    #else -16 // arbitrary unused number checked in FlxKeyList at runtime
    #end;

or CONTROL_MOD or MOD_CONTROL, and similar for SUPER_KEY or whatever

things really get hairy when we change CONTROL from 17 to 15, tho. we would need to deprecate it for a while, remove it in a major version, and then add it back after everyone has adapted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants