The problem is that the section shown stops the program ever exiting. It loops forever continually adding the function "fnident" as a routine to be called whenever keypress 122,0 occurs. It would be eating up your memory at the rate of something like 16 bytes per 20 mSecs until it crashed FS, eventually (it might take a long long time, though).
Nothing will ever call "fnident" because when the event occurs (i.e. you press the key), the Lua program is already running and the "fnident" function is not directly accessible.
It seems that you are mixing up two different ways of programming Lua for FSUIPC.
One is to have the program looping, testing something at intervals, as in:
while 1 do
if then
end
ipc.sleep(20)
end
This loops, never ending, and checks on some condition at intervals.
That is not the best way for many things, especially if the thing you are waiting for is a rare occurrence. Better by far is the Event system, in which your program merely tells FSUIPC what it wants it to monitor and what to call if it occurs, then ends. In your case, simply this:
event.key(122,0,"fnident")
In other words, just replace your entire while loop with the event.key call only.
Regards
Pete