I usually use a quest script with a processing delay of 0.1 seconds for detecting hotkeys, and they tend to look like somewhat this:
Spoiler ScriptName NightVisionHotkeyScriptint bIsHotkeyPressedBegin GameMode if bIsHotkeyPressed != IsKeyPressed HotkeyGlob set bIsHotkeyPressed to IsKeyPressed HotkeyGlob if bIsHotkeyPressed ; Do stuff when the hotkey is pressed else ; Do stuff when the hotkey is released endif endifEnd
Where "HotkeyGlob" is a global that stores the http://fose.silverlock.org/fose_command_doc.html#DirectX_Scancodes for the key you want to use.
The tutorial that I linked to has some more advanced examples, like hotkeys that have different actions if you hold them down for a certain period of time, but of course if you're not interested in that then you needn't look into it.
You'll probably want to use something like this for the code that runs when the hotkey is pressed:
Spoiler if IsImagespaceActive NightVisionISFX RemoveImagespaceModifier NightVisionISFXelseif player.GetEquipped NightVisionHelmetsList ApplyImagespaceModifier NightVisionISFXendif
Note that this code won't deactivate the night vision if the player unequips the helmet, so you'll probably want to add something like this as well:
Spoiler if IsImagespaceActive NightVisionISFX if player.GetEquipped NightVisionHelmetsList == 0 RemoveImagespaceModifier NightVisionISFX endifendif
All of that added together, with a bit of commenting and formatting, ends up like this:
Spoiler ScriptName NightVisionHotkeyScriptint bIsHotkeyPressedBegin GameMode if bIsHotkeyPressed != IsKeyPressed HotkeyGlob set bIsHotkeyPressed to IsKeyPressed HotkeyGlob if bIsHotkeyPressed ; Run this code when the hotkey is pressed ; Toggle night vision if IsImagespaceActive NightVisionISFX RemoveImagespaceModifier NightVisionISFX elseif player.GetEquipped NightVisionHelmetsList ApplyImagespaceModifier NightVisionISFX endif endif endif ; Remove the effect if the player stops wearing a helmet capable of night vision if IsImagespaceActive NightVisionISFX if player.GetEquipped NightVisionHelmetsList == 0 RemoveImagespaceModifier NightVisionISFX endif endifEnd
Cipscis