javascriptmacossafariaccessibilityhigh-contrast

How do I detect if a user has Mac OS high contrast accessibility settings enabled?


I have a React/TypeScript project, and I am trying to detect if a user has any of Mac OS's high contrast accessibility settings enabled: Invert colors, Use grayscale, Differentiate without color, Increase contrast, or an increased Display contrast setting.

I want to detect these using JavaScript/TypeScript.

So far, I can detect only Invert colors.


How do I detect if a user has any of the other Mac OS accessibility settings enabled?


More information:


Solution

  • Iam afraid it is not possible its at this moment.

    The feature in Objective-C to determine if the accessibility mode is active (boolean AXAPIEnabled(void);) has been deprecated as of 10.9 with no indication that there is a replacement. You can see it on the Apple Developer site. By extension, if developers at that level of the system no longer have access, I expect web developers would also be restricted (just as AppleScript writers seem to not have access).

    In general, testing for the presence of assistive technology or activation of assistive features is frowned upon by the users who need it most. It creates the very real risk of both well-intentioned developers breaking these features (perhaps by un-verting the page) and also of allowing bad actors to determine somebody's personal health information.

    Altought it might come in future as its in stage 5 (proposal) https://drafts.csswg.org/mediaqueries-5/#prefers-contrast

    Other than that Iam afraid you are facing dead end.