NCAPS usage

Hello

When we want to create multi-platform keyboard layout.

NCAPS is available in only in Windows and mac, perhaps hardware keyboard.

I want to use
$keymanonly: and $keymanweb:
According to documentation, these codes are semi-deprecated in favor of platform()

What would be equivalent of $keymanonly: and $keymanweb: with platform()

My reading
$keymanonly: → platform(‘hardware’)
$keymanweb: → platform(‘touch web’)

Is this good?

Also,

Line 233 has platform(‘hardware’) restriction. But when the keyboard is compiled, it throws this warning. Is it OK?

Warning: line 233 warning 2098: Extended shift flags CAPS and NCAPS are not supported in KeymanWeb

In Keyman Developer 10, NCAPS is available on web as well as Windows. So that may resolve your problem. Make sure you use store(&version) '10.0' to access 10.0 functionality.

In terms of the question itself:

The compile targets $keymanonly: and $keymanweb: can still be useful for controlling cross-platform functionality where there are limitations in the underlying platform. I still use these prefixes for those purposes. However, because they target the compiled file type, there isn’t actually a simple mapping between platform() and compile targets.

$keymanonly: means the rule will only be compiled into a .kmx file. .kmx files are used only in Keyman Desktop (Windows) and Keyman for macOS.
$keymanweb: means the rule will only be compiled into a .js file. .js files are used in KeymanWeb (all platforms), Keyman for iOS and Keyman for Android.

platform('hardware') targets any physical keyboard, including an external keyboard on an Android or iOS device. You’d need to include two rules to map to $keymanonly:

platform('windows native')
platform('macosx native')

Similarly, to match $keymanweb:, you need to target:

platform('web')
platform('ios')
platform('android')

Now, this is still not a completely 100% compatible mapping, because the $keyman* compile targets will allow a keyboard to compile when there is a compile-level feature unsupported on the opposing platform, e.g. return on KeymanWeb, .i.e. the following will compile:

$keymanonly: + 'a' > 'boo' return

But, this wouldn’t, because the code is not excluded from the web platform:

platform('windows native') + 'a' > 'boo' return'

The ideal is that we never have to use platform() or $keyman*, and the reality is that we use a mixture of these language features to get us past both current Keyman cross-platform limitations (which we’ll continue to rectify in future versions), and the more complicated multi-platform differences which usually relate to usage more than technology.

1 Like

Thank you for the thorough explanation.

is NCAPS supported in iOS and Android?

What is the state in javascript for CAPS LOCK state?

NCAPS is not supported in iOS (because hardware keyboards are not currently supported – and the concept of Caps Lock is very different in touch layouts). In Android, I believe it it supported but would need to test.

KeymanWeb supports NCAPS and CAPS, but does not support SHIFT FREES CAPS or other Caps Lock manipulation – we don’t have ability to set Caps Lock state from JavaScript.