Improved key logging