Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i try to capture a pressed function key with :

private void XtraForm1_KeyDown(object sender, KeyEventArgs e) {  
    if(e.KeyCode == Keys.F5)  
        MessageBox.Show("F5");  
}


but when i press F5 , no thing happen. also F1 and F2 decreased & increased the sound volume.

What I have tried:

it work if i pressed Fn+F5. and i don't know if my laptop keyboard is different or have special case !!!
Posted
Updated 9-Aug-19 4:45am

I think many laptops are configured this way now. I put up with it for about a month on my HP laptop but then found the setting in the BIOS to swap the behaviour so that Fn is required to change brightness, volume etc and F1 on it's own means F1. My BIOS is AMD and the setting to disable was called "Action Keys".

Alan.
 
Share this answer
 
v2
The chances are - and we have no idea what lappie you have - that the Fn key changes the keycode from a media function (volume up or down) to a specific function key code, in which case you can't "capture" the F5 key unless the user presses Fn+F5 because it doesn't appear to the OS (or any app) as a function key at all unless Fn is held down when it it pressed.
Normally, there is a little clue printed on the KB : the Fn and F1, F2, ... key text are printed in a different colour, normally blue.

That's certainly been my experience with most lappies / tablets, anyway.
And it's quite possible that your lappie "intercepts" the key press on it's own and doesn't even send it to the OS as a media key (but if it does, they are quite hard to intercept anyway)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900