Bug 552041

Summary: [mac] KeyDown event has wrong keyCode for non-english layouts
Product: [Eclipse Project] Platform Reporter: Hugo Almeida <hugoalmeida1211>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: 4.13   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Test class none

Description Hugo Almeida CLA 2019-10-11 10:57:32 EDT
Created attachment 280238 [details]
Test class

swt.version: 3.108.0.v20180904-1901 and 4.13 tested

For non-english keyboard layouts the event keyCode seems wrong on mac, and is different from both Windows and Ubuntu.

Experimental setup: see the attached file. Basically just a Text widget with a KeyListener that prints character and keyCode values of the pressed key.

I was using a physical QWERTY keyboard.

Windows/Ubuntu:
QWERTY layout, press z:
character: z
keyCode: 122

QWERTZ layout, press y (so where z is in QWERTY)
character : y
keyCode: 121

Russian layout, press я (again, where z is in QWERTY)
character: я
keyCode: 122

Mac:
QWERTY layout, press z:
character: z
keyCode: 122

QWERTZ layout, press y (so where z is in QWERTY)
character : y
keyCode: 121

Russian layout, press я (again, where z is in QWERTY)
character: я
keyCode: 1103

As you can see, there is a difference in behaviour between OSes. This is specially hard if you are trying to process keys to identify shortcuts.

I noticed Eclipse IDE Text boxes suffer from this difference in different OSes likewise. But any shortcut that is processed through a KeyListener fails precisely because of this.