What is the best cross-browser and cross-platform way to detect hardware keyboard presence with javascript?
Could you try the theoretical opposite? Instead of trying to detect keyboard hardware, why not try to detect a touch screen? With the ontouchstart event;
ontouchstart
if ('ontouchstart' in document.documentElement) { // show icon }