Open Geokureli opened 1 year ago
Since Cmd+C is the keyboard shortcut for copy, I wonder if the browser simply isn't dispatching an event to JS when that command is triggered by the user.
Does it make a difference if you call e.preventDefault()
in the KEY_DOWN
listener? That may stop the browser from copying, which could result in KEY_UP
getting dispatched.
Does it make a difference if you call
e.preventDefault()
in theKEY_DOWN
listener? That may stop the browser from copying, which could result inKEY_UP
getting dispatched.
the up event is still not* firing after trying:
stage.addEventListener(KeyboardEvent.KEY_DOWN,
function (e)
{
if (e.keyCode == C)
{
if (e.ctrlKey)
{
field.text = "Cmd + C pressed";
e.preventDefault();
}
else
{
field.text = "C pressed";
}
}
}
);
Does this happen with keys other than C (or V)?
this seems to happen with all keys, but i can now confirm that that e.preventDefault does prevent the normal action of the key combo, except cmd + w and cmd + q (close the window). notably, cmd + h normally hides the active window, and that is prevented. I assume hide, just like W or Q are system commands and not browser commands
example:
when I press Cmd+C the test says "Cmd + C pressed", but on release the text does not change until I press and release C again. If I press Cmd+C and release Cmd before C it shows "C released", as expected
Note: Even though I'm using
FlxKey.C
, I haven't instantiated aFlxGame
, or called any flixel utilities that would eat up events withpreventDefault
or something