pkamb / PowerKey

Remap your Macbook's power key to Forward Delete
MIT License
229 stars 29 forks source link

Remap Eject key #3

Closed omgmog closed 8 years ago

omgmog commented 11 years ago

I've removed the superdrive from my MBP to fit an SSD, so my eject key is pretty useless. Can this be modified to support mapping of the eject key to forwards delete?

asmeurer commented 11 years ago

You can just use KeyRemap4MacBook plus NoEjectDely for that.

pkamb commented 11 years ago

Try running the Xcode project, and un-commenting the NSLog that prints the details of a key. We'll see what kind of events the Eject key sends.

paradox460 commented 11 years ago

:+1:

omgmog commented 11 years ago

@pkamb Here's a sample with me mashing the eject key:

2013-04-26 09:42:42.989 PowerKey[8182:303] EVENT: type:14 subtype:7, eventData:1, keyCode:0, keyFlags:1, keyState:0, keyRepeat:1
2013-04-26 09:42:43.112 PowerKey[8182:303] EVENT: type:14 subtype:7, eventData:1, keyCode:0, keyFlags:1, keyState:0, keyRepeat:1
2013-04-26 09:42:45.247 PowerKey[8182:303] EVENT: type:14 subtype:10, eventData:0, keyCode:0, keyFlags:0, keyState:0, keyRepeat:0
2013-04-26 09:42:45.247 PowerKey[8182:303] EVENT: type:14 subtype:8, eventData:920064, keyCode:14, keyFlags:2560, keyState:1, keyRepeat:0
2013-04-26 09:42:45.248 PowerKey[8182:303] EVENT: type:14 subtype:8, eventData:920320, keyCode:14, keyFlags:2816, keyState:0, keyRepeat:0
2013-04-26 09:42:45.478 PowerKey[8182:303] EVENT: type:14 subtype:10, eventData:0, keyCode:0, keyFlags:0, keyState:0, keyRepeat:0
2013-04-26 09:42:45.479 PowerKey[8182:303] EVENT: type:14 subtype:8, eventData:920064, keyCode:14, keyFlags:2560, keyState:1, keyRepeat:0
2013-04-26 09:42:45.479 PowerKey[8182:303] EVENT: type:14 subtype:8, eventData:920320, keyCode:14, keyFlags:2816, keyState:0, keyRepeat:0
2013-04-26 09:42:46.767 PowerKey[8182:303] EVENT: type:14 subtype:10, eventData:0, keyCode:0, keyFlags:0, keyState:0, keyRepeat:0
2013-04-26 09:42:46.767 PowerKey[8182:303] EVENT: type:14 subtype:8, eventData:920064, keyCode:14, keyFlags:2560, keyState:1, keyRepeat:0
2013-04-26 09:42:46.768 PowerKey[8182:303] EVENT: type:14 subtype:8, eventData:920320, keyCode:14, keyFlags:2816, keyState:0, keyRepeat:0
pkamb commented 8 years ago

Thanks! The pertinent events for the Eject key are the ones below. Very similar to the power key events.

EVENT: type:14 subtype:10, eventData:0, keyCode:0, keyFlags:0, keyState:0, keyRepeat:0
EVENT: type:14 subtype:8, eventData:920064, keyCode:14, keyFlags:2560, keyState:1, keyRepeat:0
EVENT: type:14 subtype:8, eventData:920320, keyCode:14, keyFlags:2816, keyState:0, keyRepeat:0

Those work out to have these properties:

Event 1: [type: NSSystemDefined], [subtype: NX_SUBTYPE_EJECT_KEY]
Event 2: [type: NSSystemDefined], [subtype: NX_SUBTYPE_AUX_CONTROL_BUTTONS], [keyCode: NX_POWER_KEY], [keyState: keyDown];
Event 3: [type: NSSystemDefined], [subtype: NX_SUBTYPE_AUX_CONTROL_BUTTONS], [keyCode: NX_POWER_KEY], [keyState: keyUp];
pkamb commented 8 years ago

I've added eject key remapping support to the ejectKey branch, but I don't really have a way to test this myself. If anyone on this thread has a Macbook with an eject key, would you be able to test? Thanks!

This will be released in the next version.