# Class e.p.p.w.o.Key(object):

Part of elisa.plugins.pigment.widgets.osk View In Hierarchy

One given key of a virtual keyboard. A key has a type that determines its behaviour when activated:

- `Key.CHAR`: a normal character
- `Key.SWITCH`: switch between caps
- `Key.DELETE`: backspace
- `Key.PLACEHOLDER`: an invisible key
- `Key.MISC`: a key with a miscellaneous behaviour

Line # | Kind | Name | Docs
--- | --- | --- | ---
61 | Method | __init__ | Constructor.
98 | Method | to_xml | Dump the key to an XML node.
126 | Class Method | from_xml | Instantiate a key from its XML representation.

def __init__(self, ktype, kwidth, kvalues=None, label=None, image=None):
Constructor.

Parameters | ktype | the type of the key (one of (`Key.CHAR`, `Key.SWITCH`, `Key.DELETE`, `Key.PLACEHOLDER`, `Key.MISC`)) (type: `str` )
| kwidth | the relative width of the key on the row (must be between 0.0 and 1.0, the sum of the widths of the key on one row should not exceed 1.0) (type: `float` )
| kvalues | the value of the key (depends on its type). if ktype is `Key.CHAR`, then kvalues is a `dict` associating each cap to a string value if ktype is `Key.SWITCH`, then kvalues is a `list` of caps to cycle through when switching if ktype is `Key.DELETE`, then kvalues is ignored if ktype is `Key.PLACEHOLDER`, then kvalues is ignored if ktype is `Key.MISC`, then kvalues is a miscellaneous string value (type: `dict` of `str`, or `list` of `str`, or `None`, or `str` )
| label | the label to display on the graphical representation of the key (type: `str` )
| image | an optional image resource to display on the graphical representation of the key (type: `str` )

def to_xml(self, document):
Dump the key to an XML node.

Parameters | document | the XML document for which to generate the node (type: `xml.dom.minidom.Document` )
Returns | an XML node representing the key (type: `xml.dom.minidom.Element` )

@classmethod
def from_xml(cls, key_node, caps):
Instantiate a key from its XML representation.

Parameters | key_node | the XML representation of the key (type: `xml.dom.minidom.Element` )
| caps | the list of caps of the keyboard (type: `list` of `str` )
Returns | a key (type: `Key` )