platform() statement tests the device on which the Keyman keyboard is running
platform("platformConstraint") ... > ... if(&platform = "platformConstraint") ... > ...
- The platform constraint to test.
&platform variable system store checks the current platform a keyboard is running on. This test is
slightly different to all other
if() tests, because it is not performing an exact string
match but rather matching each token against a set of valid tokens. To help clarify this in code, use the
syntax rather than the
if(&platform ...) syntax.
Keyman keyboards can be targeted to run on a number of different platforms, and have slightly different behaviour on each of those platforms. The definition of a platform is somewhat rubbery, consisting of items such as operating system, application, browser, form factor and input type. Accordingly, the platform constraints are correspondingly loose.
A platform constraint is list of one or more platform identifiers separated by spaces. There is no order defined for the list. The identifiers are case-insensitive.
The key requirement for testing a given platform constraint is that all factors must be met for the constraint to pass. If an unknown constraint is included, then the test fails (note: new behaviour for Keyman 10).
touch android tablet native would match Keyman for Android on an Android
android tablet would match Keyman for Android on an Android tablet or KeymanWeb in a browser
on an Android tablet.
blackberry would not match on any platform (as Blackberry is not a supported
platform as of Keyman 10).
Platform constraint definition
The platform constraints are broken down into several components. Each component is optional. Typically, each component should be used at most once in a platform definition. Each component will currently be alphanumeric only; future versions may allow for version testing.
The components are: User Interface, Operating System, Form Factor, Application, and Browser.
- A touch-screen keyboard, such as an iPhone, iPad, Android phone or tablet or Windows phone.
- Using a physical keyboard, e.g. Keyman Desktop, or a touch device but with an external keyboard attached (supported on Android)
- Microsoft Windows, desktop, server and mobile versions
- Any device running the Android operating system
- Any iPhone, iPad, iPod or other device running the iOS operating system
- Linux or other UNIX-style operating systems.
- Desktop, laptop and server class devices
- Touch-based tablet sized devices.
- Mobile phones and similar small devices. This may include very small tablets, where the engine determines that a phone sized keyboard is more appropriate than a tablet sized keyboard.
- Keyman Desktop, Keyman for iPhone and iPad, Keyman for Android, Keyman for macOS, etc.
- Keyman Engine for Web on any platform and any browser
Browser tests apply only to KeymanWeb. Be careful when targeting specific browsers, as language support in browsers tends to change rapidly. (Note: even though Keyman for Android and Keyman for iPhone and iPad use KeymanWeb internally, browser tests will not match in those apps.
- Keyman Engine for Web in Internet Explorer
- Keyman Engine for Web in Chrome
- Keyman Engine for Web in Firefox
- Keyman Engine for Web in Safari
- Keyman Engine for Web in Opera
- Keyman Engine for Web in Edge
platform('ios native') + 'a' > 'α' platform('android native') + 'a' > 'ά'
With these two rules, pressing the key "a" in Keyman for Android would result in "ά", whereas pressing the key "a" in Keyman for iPhone and iPad would result in "α". In KeymanWeb on those platforms, or on any other platform, the "a" key would just result in the default behaviour of "a", because neither rule would match.
platform() statement can be used in keyboards on all platforms.
|Windows||macOS||Linux||Desktop web||Mobile web||iOS||Android|
- Keyman 10.0
- Behaviour for unrecognised tokens was changed to treat unrecognised tokens as a failure to match instead of succeeding as in earlier versions; this gives better backward and forward compatibility; noted that tokens are case-insensitive; noted that browser tests only apply in KeymanWeb; browser 'edge' was split out from 'ie'; an undocumented feature allowing targeting specific versions of Windows was removed; added synonyms for 'macosx'.
- Keyman 9.0
platform()statement was introduced in Keyman 9.0.