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


You are not allowed to post comments on this tracker with your current authentification level.

bug #25395: event key codes incompatible to apple

Submitted by:  Riccardo Mottola <rmottola>
Submitted on:  Sat Jan 24 10:16:46 2009  
Category: BackendSeverity: 2 - Minor
Item Group: Change RequestStatus: Need Info
Privacy: PublicAssigned to: None
Open/Closed: Open

Wed Feb 9 08:36:17 2011, 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>
Project Member
Sun Feb 1 12:16:32 2009, comment #4:

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

Fred Kiefer <FredKiefer>
Project Member
Wed Jan 28 08:40:22 2009, 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>
Project Member
Sat Jan 24 17:22:00 2009, 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>
Project Member
Sat Jan 24 16:18:33 2009, 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>
Project Member
Sat Jan 24 10:16:46 2009, 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>
Project Member


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Feb 9 08:36:17 2011rmottolaSeverity1 - Wish=>2 - Minor
    Sun Feb 1 12:16:32 2009FredKieferSeverity3 - Normal=>1 - Wish
      Item GroupBug=>Change Request
    Sat Jan 24 16:18:33 2009CaSStatusNone=>Need Info

    Back to the top

    Powered by Savane 3.1-cleanup1