I don't see what your JS function is supposed to do. Also, the element and its ID need to be in the DOM, like a div for instance; certainly not a button instance name inside an embeded swf. A JS function, like AS, can accept parameters, though. So if you need to pass a variable value, insert it in your JS.

if you HAVE to use javascript, use ExternalInterface.call to call the JS from flash.

If not, this will suffice in Flash alone. Use a dyn txtfield with instance name keynum. Since you'll need to test the swf in standalone. The Function keys in authoring or test mode being reserved :

PHP Code:
var myListener:Object = new Object();
myListener.onKeyDown = function () {
    if (
Key.getCode() == 113) {
        
keynum.text "F2 pressed";
    }
}
myListener.onKeyUp = function () {
    
keynum.text "F2 released";
}
Key.addListener(myListener); 
gparis