If you're feeding from Lua, you should be able to check the Apple II zero page variables to determine when Applesoft is ready to accept input.