Listening to stdin in Swift
问题 Currently I am trying to listen to user input from the command line in my swift application. I am aware of the readLine() method but it does not really fit my needs. I want to listen for data being inserted on the command line. Like when a user is pressing the ‘up key’ inside the terminal. Something like what can be done in Node.js: stdin.on( 'data', function( key ){ if (key === '\u0003' ) { process.exit(); } // write the key to stdout all normal like process.stdout.write( key ); }); I tried