<AWT Dev> Workaround for bug JDK-8167263: "[macos] Java keyPressed function of Key Listener doesn't work for W, A, S, D"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

<AWT Dev> Workaround for bug JDK-8167263: "[macos] Java keyPressed function of Key Listener doesn't work for W, A, S, D"

Gareth Randall
Hi,

I have a workaround for bug JDK-8167263: "[macos] Java keyPressed
function of Key Listener doesn't work for W, A, S, D"

However, I do not have rights to post on the discussion for this bug so
perhaps someone could post this message to the thread?
The thread is at: https://bugs.openjdk.java.net/browse/JDK-8167263

Workaround:

The problem of missing events is related the macOS feature which offers
the character accent menu when a key is held down, instead of
auto-repeating.

I experienced the same problem described in the bug but with a different
set of keys. (In my case Z, X, : and .) When I disabled the character
accent menu the problem disappeared and key events auto-repeated as
expected.

To disabled the character accent menu and enable auto-repeat, type the
following at the command prompt:

     defaults write -g ApplePressAndHoldEnabled -bool false

This can be reversed with the following:

     defaults write -g ApplePressAndHoldEnabled -bool true

Hopefully this will provide a pointer for your team to work out how to
do this programmatically, but until then the workaround can help
interested users.

Yours,

Gareth
Reply | Threaded
Open this post in threaded view
|

Re: <AWT Dev> Workaround for bug JDK-8167263: "[macos] Java keyPressed function of Key Listener doesn't work for W, A, S, D"

Sergey Bylokhov
Hi, Gareth
Thank you for this workaround, I have added a comment to the bug.

On 07/12/2017 02:03, Gareth Randall wrote:

> Hi,
>
> I have a workaround for bug JDK-8167263: "[macos] Java keyPressed
> function of Key Listener doesn't work for W, A, S, D"
>
> However, I do not have rights to post on the discussion for this bug so
> perhaps someone could post this message to the thread?
> The thread is at: https://bugs.openjdk.java.net/browse/JDK-8167263
>
> Workaround:
>
> The problem of missing events is related the macOS feature which offers
> the character accent menu when a key is held down, instead of
> auto-repeating.
>
> I experienced the same problem described in the bug but with a different
> set of keys. (In my case Z, X, : and .) When I disabled the character
> accent menu the problem disappeared and key events auto-repeated as
> expected.
>
> To disabled the character accent menu and enable auto-repeat, type the
> following at the command prompt:
>
>      defaults write -g ApplePressAndHoldEnabled -bool false
>
> This can be reversed with the following:
>
>      defaults write -g ApplePressAndHoldEnabled -bool true
>
> Hopefully this will provide a pointer for your team to work out how to
> do this programmatically, but until then the workaround can help
> interested users.
>
> Yours,
>
> Gareth


--
Best regards, Sergey.