Click here to Skip to main content
14,330,375 members
Rate this:
Please Sign up or sign in to 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)  

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 !!!
Updated 9-Aug-19 4:45am
Rate this:
Please Sign up or sign in to vote.

Solution 1

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".

Rate this:
Please Sign up or sign in to vote.

Solution 2

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)

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100