Detect keyboard type (ANSI, ISO, etc.) via AppleScript?

I’ve searched for a way to test whether the current keyboard is an ANSI or ISO keyboard, but can’t find one. If anyone knows a way to achieve this in AppleScript, I’ll be very grateful for details.

To you mean to detect the difference between ANSI vs. ISO (123 vs 124 keys?) or between ISO and something very different such as Dvorak etc? Do you want the layout of the physical keyboard? That may be tricky because a user could have multiple different keyboards connected.

There’s a solution to every of these possibilities, so please be more specific, possibly even give an example of what you want to use the information for, so we can better help.

This may also be helpful: macos - Determine OS X keyboard layout ("input source") in the terminal/a script? - Stack Overflow

Thank you. I’m already using one of the methods on the linked page to determine the layout, but looking for a method of detecting ANSI/ISO/JIT for the (very limited) purpose of getting the keyboard to behave correctly in the SheepShaver/BasiliskII emulators (which emulate PPC and 68K Macs). Some keyboards need the emulators to load a “keycodes” file which tell the emulator what keystrokes to enter for keys that are different in ANSI and ISO keyboard types.

There’s a long discussion of the problem here: