(Generally, to avoid confusion, the classic version is written "Mac OS" and the modern version "macOS", with various versions of "OS X" between.)
Modern macOS can do this too, you just have to ask the user for permission. You can see it in System Settings → Privacy & Security → Input Monitoring