bugGNUstep - Bugs: bug #25395, event key codes incompatible to...


bug #25395: event key codes incompatible to apple

Submitter:  Riccardo Mottola <rmottola>
Submitted:  Sat 24 Jan 2009 10:16:46 AM UTC
Category:  Backend Severity:  2 - Minor
Item Group:  Change Request Status:  Need Info
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Wed 09 Feb 2011 08:36:17 AM UTC, comment #5: 

Generally I found GNUstep is currently incompatible also among different operating systems/environments, which makes the usage of keyCodes under GNUstep impossible.

Riccardo Mottola <rmottola>
Group Member
Sun 01 Feb 2009 12:16:32 PM UTC, comment #4: 

Made this report a change request. I think it is still valid, but of very low priority.

Fred Kiefer <FredKiefer>
Group Member
Wed 28 Jan 2009 08:40:22 AM UTC, comment #3: 

I see this is a moot topic here. I did consult only the Apple documentation and was a bit confused by things now working properly afterwards.

An added point is here probably that "esc" cannot be handled by characters and it is not present among the unicode constants, which I find very strange (check the second link posted by Matt)

Currently I worked around this by defining myself a constant and assigning it different values between gnustep and mac. I hope that GNUstep returns the same code on different pplatforms.

Secondly, I agree that "hardware independent " is also misleading here: it means only that the same os run on different hardware will return the same code, it does not speak of different implementations. But, of course, since OpenStep is no more, APple does not consider Cocoa itself portable, so it ends up just meaning that different apple computers and keyboards will return the same key code. Our scenario is slightly more varied!

We can close this bug if we think there is no good solution, but it will remain of course a point where a potential user porting his mac app might remain confused, maybe we a wiki entry?

Riccardo Mottola <rmottola>
Group Member
Sat 24 Jan 2009 05:22:00 PM UTC, comment #2: 

at one point in time i remember the exact opposite was true, the internet agrees.


Returns the code for the keyboard key associated with the receiving key event. Its value is hardware-dependent. Raises an NSInternalInconsistencyException if sent to a non-key event.


The virtual key code. The returned value is hardware-independent.

from the book "cocoa programming" by anguish, buck, and yactman
"this is a device-dependent code. while it is provided for key-down, key-up, and flags changed events, it is generally a very bad idea to use it."

the first version of Hillegass's "cocoa programming for Mac OS X" also mentions it as hardware dependent and afaict has no example usage.

it doesn't appear that there exists any apple provided definition
here is a thread on the subject.


matt rice <ratmice>
Group Member
Sat 24 Jan 2009 04:18:33 PM UTC, comment #1: 

I'm not entirely sure this is a bug ... saying that the codes are device independent is not the same as saying they are system independent, and I can't actually find any definition of what the key codes should be (except for function keys ... and we probably already use those definitions) in the documentation or Apple's AppKit headers.

Please could you provide a link to a definition of what those keycode values are?

Richard Frith-Macdonald <CaS>
Group Member
Sat 24 Jan 2009 10:16:46 AM UTC, original submission:  

NSEvent documentation from Cocoa states:

- (unsigned short)keyCode

Returns the virtual key code for the keyboard key associated with the receiving key event. Its value is hardware-independent.


we return different keycodes from Apple.

This is wrong both on Unix and Windows.

Riccardo Mottola <rmottola>
Group Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by FredKiefer (Posted a comment)
  • -email is unavailable- added by ratmice (Posted a comment)
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by rmottola (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-02-09 rmottola Severity1 - Wish 2 - Minor
    2009-02-01 FredKiefer Severity3 - Normal 1 - Wish
        Item GroupBug Change Request
    2009-01-24 CaS StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code