DESCRIPTION
A simple script used to check if a given key is valid for for the Set Key command. This is useful when the user would like to use a keyboard key as shortcut/hotkey in their script but need to check if the key is a valid one.
USAGE
load the script using the run command
If the key specified is a valid one as defined in Set Key then it returns the value of the keystroke. Otherwise, it returns None.
For an example that calls this script, see Jump.
PyMOL API
<source lang="python">
from pymol import cmd
import re
allowed_keys=re.compile('(F1|F2|left|right|pgup|pgdn|home|insert|(CTRL-[A-Z])|ALT-[A-Z0-9])')
def check_key (keystroke):
"""
Author Sean M. Law
University of Michigan
seanlaw_(at)_umich_dot_edu
"""
keystroke=keystroke.strip('\"\)
out=allowed_keys.search(keystroke)
..→