CCoeEnv::Static()-> RootWin().CaptureKey(xxx,0,0 );//这里 xxx 是iCode值,非iScanCode值
1、资料一:Bring application to foreground with a keypress(http://wiki.forum.nokia.com/index.php/Bring_application_to_foreground_with_a_keypress)
Inorder to capture the keys while you application under background you've to override CCoeAppUi::HandleWsEventL to your AppUi. With the use of RWindowGroup::CaptureKeyUpAndDowns() you can capture the keys from an application. Below is some sample code which will show you basically how to do it, you may found some additional bit of code which you may use.
The mmp file
The header file
The cpp file
2、资料二:Capturing keys in background(http://wiki.forum.nokia.com/index.php/Capturing_keys_in_background)
The CKeyCapturer implementation illustrates how to capture key events in a background process. Note that you need to define the key to be captured when using the CaptureKey() function (example is capturing the EKeyDevice0 key).
Also note that if the key should also be usable for the focused application, you need to manually forward it. This is already handled by the example as shown in the RunL() method. The callback interface function will return EFalse if the key is supposed to be forwarded to the focus application and ETrue if the key was consumed.
This example code should work with all platforms, but when used with S60 3rd Edition devices you need to have the SwEvent capability.
If you want to capture basic application keys in a foreground application you can use the standard OfferKeyEventL() method implemented in your CCoeControl derived class. If your application does not implement the standard application framework, you could also try using CKeyCapturer2 implementation.
Note! |
---|
This will not capture volume keys or the multimedia keys such as the play key on the headset. For this you will need to use TSS000432 - Utilising media keys |
Header required:
Library Required:
Capability Required:
CapturingKeys.h
CapturingKeys.cpp
If you need to capture keys that are intended for applications like Google Maps or Nokia Maps, where a key held down makes multiple events you might better use this code in the RunL function:
3、资料三:Capture Key sequence in non-gui application(http://wiki.forum.nokia.com/index.php/Capture_Key_sequence_in_non-gui_application)
'''KeyCapturer.cpp'''