Maybe this would better belong in the modding or FRED subforum, please move if so.
In FotG we needed to detect specific physical keypresses in a couple of places, and in such a case key-pressed doesn't work because the player might have bound their keys differently. I wrote a very simple script to allow that to be done, so I might as well post it here in case someone finds it useful:
#Conditional Hooks
$Application: FS2_Open
$On Game Init: [
    keypressed = function(keyname)
        if keypresses[keyname] then
            return 1
        else
            return 0
        end
    end
    keyreset = function(keyname)
        if keypresses[keyname] then
            keypresses[keyname] = nil
        end
    end
]
$State: GS_STATE_GAME_PLAY
$On Gameplay Start: [
    keypresses = {}
]
$On Key Pressed: [
    local key = hv.Key
    keypresses[key] = true
]
#End
Put that in keypresses-sct.tbm, after which you can use the two functions just like key-pressed and key-reset:
$Formula: ( when 
   ( > 
      ( script-eval-num 
         "keypressed('Backspace')" 
      )
      0 
   )
   ( play-sound-from-table 0 0 0 "78" ) 
)
+Name: PlaySoundOnBackspace
+Repeat Count: 1
+Interval: 1
$Formula: ( when 
   ( has-time-elapsed 5 )
   ( script-eval "keyreset('Backspace')" ) 
)
+Name: ResetBackspace
+Repeat Count: 1
+Interval: 1
The function returns 0 if the key has not been pressed, and 1 if it has been, hence the use of the > operator and script-eval-num.