tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.keyboard"
reveal anchor "keyboardTab" of pane id "com.apple.preference.keyboard"
end tell
tell application "System Events" to tell process "System Preferences"
delay 0.3
set thePopUp to pop up button 2 of tab group 1 of window "Keyboard"
set current to value of thePopUp
click thePopUp
if current is equal to "F1, F2, etc. Keys" then
click menu item 1 of menu 1 of thePopUp
else
click menu item 3 of menu 1 of thePopUp
end if
end tell
quit application "System Preferences"