Apple Wireless Keyboard Driver for Windows WinA1314
What is WinA1314
WinA1314 is a kernel mode driver for the Apple Wireless Keyboard in Windows.
Why I Wrote This
The Apple Wireless Keyboard (A1314) is directly recognised by Windows as a HID Keyboard device but has a few functional issues:
- The Fn and the Eject keys are dead.
- The Ctrl key is in an unusual position (Ctrl and Fn are swapped).
- Certain essential keys are missing for Windows operation, such as Print Screen, Insert, Delete, Page Up/Down, Home and End.
The SharpKeys application to remap the keyboard keys.
This application modifies the Windows registry to perform key remapping (of scancodes to virtual key codes), which is an intrinsic Windows functionality. It is quite low level but the problem with this approach is that certain keys (specifically the Fn and Eject) never make it to the operating system. They are ignored by the default keyboard class driver (kbdclass.sys). I needed to swap the Fn and Ctrl keys as well as assign functions to them. In addition, if I remapped the keys that do make it to the operating system using this tool, the remapping would have been universal, that is for all my keyboards, which was something I did not want. Therefore this solution was abandoned.
The BootCamp Apple Keyboard drivers for Windows.
This looked like a promising solution. Bootcamp installs a separate driver (KeyMagic.sys), which recognises all of the keyboard keys and assigns mappings to them on Windows, but with one drawback. You cannot fully control the mappings. You can fiddle around with the registry key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\KeyMagic” which defines some of them but there is no way to swap the Ctrl and Fn keys or generally assign different base operations to these keys. For instance, you cannot make Fn behave as the Ctrl key or Eject as Delete.
These are generally well done but as user-level applications they intercept the keypresses by using the Windows Hook APIs. Unfortunately this approach has a few shortcomings:
- Cannot intercept ctrl-alt-del on the logon or lock screens.
- Cannot discriminate between keyboards. This is a problem if you are using two keyboards (most commonly in a laptop).
- Does not work in certain applications such as in Remote Desktop.
- The application needs to be explicitly run at each logon session.
Write and install a LowerFilter device filter driver to intercept keys before they reach the keyboard driver and the higher layers of the operating system.
That is the right way to go but unfortunately due to the new Device Driver Signature Enforcement requirements on 64-bit Windows systems and the high price of a code signing certificate, I did not like to follow that route.
WinA1314 is implemented as a Windows driver and service module that utilizes the Interception kernel mode driver (keyboard.sys) implemented by Francisco Lopes. This driver is already signed and allows the interception and modification of keys at kernel level. It is implemented as an upper filter above the kbdclass.sys, the upper level keyboard class filter driver.
Using the above solution, WinA1314 intercepts keystrokes before they reach user-level and thus overcomes the shortcomings of the previously described user-mode applications.
The WinA1314 Windows service is completely written in C++. It has no extra runtime library or additional platform requirements (such as .Net) on the host machine. It has a minimal memory footprint and it’s operation is completely event-based, without the use of threads.
Default Key Mapppings
WinA1314 installs the following key mappings by default, which can be altered after installation in any desirable setup.
|Input Key(s)||Output Key|
|Ctrl||Fn (configurable at installation)|
|Fn||Ctrl (configurable at installation)|
|Left/Right Alt||Left/Right Windows (configurable at installation)|
|Left/Right Windows||Left/Right Alt (configurable at installation)|
|Fn + Backspace||Delete|
|Fn + Enter||Insert|
|Fn + F3||(App) My Computer|
|Fn + F4||(App) Calculator|
|Fn + F5||Pause/Break|
|Fn + F6||Print Screen|
|Fn + F7||previous track|
|Fn + F8||play/pause|
|Fn + F9||next track|
|Fn + F10||mute|
|Fn + F11||volume down|
|Fn + F12||volume up|
|Fn + Up||Page Up|
|Fn + Down||Page Down|
|Fn + Left||Home|
|Fn + Right||End|
You can temporarily stop the driver by issuing the following command at the command prompt:
net stop WinA1314
To start again, type:
net start WinA1314
You can specify your custom key mappings by adding/modifying or deleting entries in the HKEY_LOCAL_MACHINE\SOFTWARE\WinA1314\Map registry key.
The values format is the following:
Src Key ScanCode, Src Key Extra, Reserved (0),
Dst Key ScanCode, Dst Key Extra, Reserved (0),
Dst Key (when Fn pressed) ScanCode, Dst Key (when Fn pressed) Extra, Reserved (0)
For instance, to swap keys “A” and “B” on the keyboard you will need to add the following two entries:
The key scancode can be entered in base 10 or in hex. If it is entered in hex, it should be prefixed with “0x”.
To make key “A” behave as “B” when the Fn key is pressed, add the following entry:
If you want to remap the Fn key, you need to be aware that the Fn key is internally (does not make it to the OS) mapped to the scancode 0xff.
The “Extra” value is needed for some keys (such as Alt, Home, etc.). It can be used to encode the extended bit values such as E0 and E1. The extended bit value E0 is represented by number 0x2 and the extended bit E1 is represented by number 0x4.
For instance, to map the arrow down key to page down but only when the Fn key is pressed together, you will need to add the following value (numbers in hex now):
To discover key scancodes, you can use keyview.exe. Just look at the “Scan” value (which is shown in decimal but WinA1314 can also accept decimal so no need to convert). Also whenever you see the “Ext” set to Yes, you will need to set the value “2” to the “Src/Dst Key Extra” field of the WinA1314 registry. For example, if you press the arrow down key, in keyview.exe you will see: Scan=80 Ext=Yes. This means that this key in WinA1314 should be entered as “80,2,0”. If you press key “A”, in keyview.exe you will see: Scan=30, Ext=No. This key will be entered in WinA1314 as “30,0,0”.
If you modify any registry settings for the driver, you will need to restart it from the command line using the previously described procedure.
Swapping the Fn and Ctrl Keycaps
After installing the driver you can optionally remove and swap the Fn and Ctrl keycaps as they have exactly the same size on this keyboard. This can be done by inserting two fingernails just underneath the two upper corners of the key and pulling it up gently.
1. ‘Ctrl + LeftShift + T’ key combination (commonly used in Google Chrome to re-open closed tabs) does not work.
As a workaround use the right shift instead.
2. It does not work on a Mac running windows through Bootcamp.
Your option is to natively install Windows. I do not own a Mac to further check why but I have the impression that Bootcamp modifies the hardware ID of the Apple keyboard and it does not get detected by the driver.
3. It does not work for the wired Apple keyboard versions.
It is not designed to work with them.
4. The Delete key (mapped on Eject) does not currently work in typematic mode (auto-repeat).
To overcome this, use the alternative ‘Fn + Backspace’ key mapping.
5. The Delete key (mapped on Eject) does not work immediately after reboot.
This is because the WinA1314 service, that controls the keyboard, might need a few seconds to start after you see the log-on screen on your computer.
6. The Fxx keys do not work or seem to have a strange behaviour.
This is may be the case if you have not uninstalled the A1314 Apple Bootcamp driver.
You must have administrator rights on the OS for installation.
WinA1314 requires Windows 7 or higher. Installation on Windows Vista is also allowed, but I have not tested it.
If you have any thirt party applications such as the UWAKS or the Apple Bootcamp drivers already installed on your system, please uninstall them first before installing WinA1314.
Disclaimer and Download
Although special care was taken during implementation and testing I accept no responsibility for any kind of damage that could be caused by installing and using this software. By agreeing to download and install this software, you also agree to take full responsibility of any such circumstance.
External Download Links/Reviews:
For bug or questions please mail me at: , or you can leave a comment here.
A big thanks to all of you who sent comments, improvement ideas, bug reports or even donations!
You can download it here. To build the project, you will need Visual Studio 2012 and the Windows Driver Kit 8.