Would the key be pressed and released to switch to a given view, or held down?
In case of the former, you could use the "Device State" tab to check whether the key is still pressed.
In case of the latter, using a variable to keep track of the currently selected view would be an option, and can work when set up correctly.
Have you read the documentation on the features you've mentioned? The command scope, denoted by the "~" prefix, would not apply if the intent is to make a variable available to other commands, which it is by default.
These topics may be of use in addition to the official documentation:
Control flow (If, Else, ElseIf, Loop, Jump) basicsVariables and tokens summed upAs mentioned in the second topic, the Integer datatype would be most suitable to this application, given that the Small Integer datatype is essentially deprecated.
A basic setup could look something like
When I say:
View 1Begin Integer Compare : [currentView] Does Not Equal 1
Press NumPad 1 key and hold for 0.1 seconds and release
Set integer [currentView] value to 1
End Condition
Where each of your view commands (assuming they are separate) would contain the same actions, but with the numbers and key changed appropriately.
If preferred, a message could also be added to notify of a repeat call to the same view, E.G.
Begin Integer Compare : [currentView] Does Not Equal 1
Press NumPad 1 key and hold for 0.1 seconds and release
Set integer [currentView] value to 1
Else
Say, 'View is already selected'
End Condition