I think the simplest way is an add this Keyboard InputsToggle() here:
-------------------------------------------------------
-- PLC First Run
-------------------------------------------------------
if (testcount == 1) then --Set Keyboard input startup state
local iReg = mc.mcIoGetHandle (inst, "Keyboard/Enable")
mc.mcIoSetState(iReg, 1) --Set register to 1 to ensure KeyboardInputsToggle function will do a disable.
KeyboardInputsToggle() -- This make KeyboardInputsToggle disable
prb.LoadSettings()
KeyboardInputsToggle() --This make KeyboardInputsToggle enable
Or try add KeyboardInputsToggle() to UP and DOWN script of Enable button.