Well, as far as user privileges, you could have a separate hidden file for each user account that contains their privilege level. To obtain the different privilege levels you could read them into a table along with other user specific data, like username and password.
As for always listening for key presses, you could use the parallel API combined with loadstring to get a function version of the program you wish to run.
Here's an example:
tStack = {}; -- The program, or rather, function stack.
function ListenForKeys() -- Listens for a key press and then handles the press.
local event, key = os.pullEvent( "key" );
if key == 28 then -- If enter was pressed.
os.shutdown(); -- Shutdown the machine.
end
end
function LoadProgram() -- Returns a function or false.
local File = fs.open( "TestProgram", "w" ); -- Open the file containing the program we want to run.
local FileContents = File.readAll(); -- Get the contents of the file.
File.close(); -- Close the file.
local Program = loadstring( FileContents ); -- Attempt to load the program string into a function.
if Program then -- If there were no interpretation errors; Program loaded correctly.
return Program; -- Return the function.
else -- If there was some kind of error.
return "FailedToLoad"; -- Return false.
end
end
function ExecuteStack( ... ) -- Executes all functions with the parallel API that are passed as arguments.
parallel.waitForAny( unpack( arg ) ); -- Execute the functions passed.
end
tStack[#tStack+1] = ListenForKeys; -- Add the key listening function to the stack.
tStack[#tStack+1] = LoadProgram(); -- Add the loaded function to the stack.
if tStack[#tStack] ~= "FailedToLoad" then -- If the loaded function is not equal to nil.
-- Run the main program loop.
while true do
ExecuteStack( unpack( tStack ) ); -- Execute all functions with the parallel API that are within the stack.
end
else
print( "Interpretation error in stack." );
end
I haven't tested the code above, but I think that it is what you are looking for.
Hope I helped!

/>