// 1. Wait for the shiny:connected event
$(document).on('shiny:connected', function(event) {
// 2. Access to the Shiny JS object
Shiny.setInputValue(
// 3. Definine the id to use
'isMac',
// 4. Confirm if the user has MacOS
(navigator.appVersion.indexOf('Mac') != -1)
);
});