You can’t reliably detect screen readers
When I hold workshops on accessibility I am often asked how to detect screen readers. The answer is that you can’t, at least not in a reliable way.
The main reason is that screen readers run alongside (or on top of, if you prefer) regular web browsers and do not have a user agent string of their own that you can sniff.
While it is possible to use Flash to detect whether some assistive technology is active, it is quite unreliable:
- It obviously requires Flash
- It doesn’t detect screen readers, it detects assistive technology that makes use of Microsoft Active Accessibility (MSAA)
- It only works on Windows, and only with some screen readers
Steve Faulkner talks more about this in Developer Beware: Using Flash to Detect Screen Readers.