added printf wrapper and keyboard callback function