how to display some text in blender 3Dviewport? How to display some text in blender 3Dviewport?
like screencast addon display pressed keys?
You can draw on the 3D viewport by registering a draw handler and using the bgl and blf modules.

Registering the draw handler is done via bpy.types.SpaceView3D.draw_handler_add(). Just browse through the bundled Blender add-ons to get lots of examples on how this is used in practice.