How to use if() statement in keyman developer?


#1

Hi all,
I am making a keyboard layout file in keyman developer. But i can’t understand the proper usage of “If()” statement from language guide. Although, i have a little experience in programming, i cant get the idea completely.
Main reason is the variables in example code. It shows me a variable named “opt” and i cant find the value of “opt” anywhere.
Let me explain my problem precisely.
Let’s say that i have a store like this ;
store(MyStore) “aeiou”.
And if the context is any letter from this store, if key “1” is pressed, i need the output to be context + b
How to do that with if statement.
This is my pseudo code
If (context = any(MyStore)) + “1” > index(MyStore, 1) “b”


#2

You can find an example of the if() statements being used depending on the platform in this test keyboard:

Your scenario may not need the if() statement. Does the following work for you?

store(MyStore) 'aeiou'

group(main) using keys

any(MyStore)+ '1' > index(MyStore, 1) 'b'

#3

Yes, agree with @Darcy, I think that the any() statement does what you are wanting in matching context.