---
name: "SoKeyboardEvent"
section: "3"
platform: "linux"
package: "coin"
version: "1:4.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SoKeyboardEvent"
---

# SoKeyboardEvent(3)

The SoKeyboardEvent class contains information about keyboard interaction.

## NAME

SoKeyboardEvent - The **SoKeyboardEvent** class contains information about keyboard interaction.

## SYNOPSIS

\#include \<Inventor/events/SoKeyboardEvent.h\>

Inherits **SoButtonEvent**.

### Public Types

enum **Key** { **ANY** = 0, **UNDEFINED** = 1, **LEFT\_SHIFT** = 0xffe1, **RIGHT\_SHIFT**, **LEFT\_CONTROL**, **RIGHT\_CONTROL**, **LEFT\_ALT** = 0xffe9, **RIGHT\_ALT**, **NUMBER\_0** = 0x0030, **NUMBER\_1**, **NUMBER\_2**, **NUMBER\_3**, **NUMBER\_4**, **NUMBER\_5**, **NUMBER\_6**, **NUMBER\_7**, **NUMBER\_8**, **NUMBER\_9**, **A** = 0x0061, **B**, **C**, **D**, **E**, **F**, **G**, **H**, **I**, **J**, **K**, **L**, **M**, **N**, **O**, **P**, **Q**, **R**, **S**, **T**, **U**, **V**, **W**, **X**, **Y**, **Z**, **HOME** = 0xff50, **LEFT\_ARROW**, **UP\_ARROW**, **RIGHT\_ARROW**, **DOWN\_ARROW**, **PAGE\_UP**, **PAGE\_DOWN**, **END**, **PRIOR** = 0xff55, **NEXT**, **PAD\_ENTER** = 0xff8d, **PAD\_F1** = 0xff91, **PAD\_F2**, **PAD\_F3**, **PAD\_F4**, **PAD\_0** = 0xff9e, **PAD\_1** = 0xff9c, **PAD\_2** = 0xff99, **PAD\_3** = 0xff9b, **PAD\_4** = 0xff96, **PAD\_5** = 0xff9d, **PAD\_6** = 0xff98, **PAD\_7** = 0xff95, **PAD\_8** = 0xff97, **PAD\_9** = 0xff9a, **PAD\_ADD** = 0xffab, **PAD\_SUBTRACT** = 0xffad, **PAD\_MULTIPLY** = 0xffaa, **PAD\_DIVIDE** = 0xffaf, **PAD\_SPACE** = 0xff8d, **PAD\_TAB** = 0xff89, **PAD\_INSERT** = 0xff9e, **PAD\_DELETE** = 0xff9f, **PAD\_PERIOD** = 0xff9f, **F1** = 0xffbe, **F2**, **F3**, **F4**, **F5**, **F6**, **F7**, **F8**, **F9**, **F10**, **F11**, **F12**, **BACKSPACE** = 0xff08, **TAB** = 0xff09, **RETURN** = 0xff0d, **ENTER** = 0xff0d, **PAUSE** = 0xff13, **SCROLL\_LOCK** = 0xff14, **ESCAPE** = 0xff1b, **DELETE** = 0xffff, **KEY\_DELETE** = DELETE, **PRINT** = 0xff61, **INSERT** = 0xff63, **NUM\_LOCK** = 0xff7f, **CAPS\_LOCK** = 0xffe5, **SHIFT\_LOCK** = 0xffe6, **SPACE** = 0x0020, **APOSTROPHE** = 0x0027, **COMMA** = 0x002c, **MINUS** = 0x002d, **PERIOD** = 0x002e, **SLASH** = 0x002f, **SEMICOLON** = 0x003b, **EQUAL** = 0x003d, **BRACKETLEFT** = 0x005b, **BACKSLASH** = 0x005c, **BRACKETRIGHT** = 0x005d, **GRAVE** = 0x0060 }\

Public Types inherited from **SoButtonEvent** enum **State** { **UP**, **DOWN**, **UNKNOWN** }\

### Public Member Functions

virtual **SoType** **getTypeId** (void) const\
 **SoKeyboardEvent** (void)\
 virtual **~SoKeyboardEvent** ()\
 void **setKey** (**Key** key)\
 **Key** **getKey** (void) const\
 void **setPrintableCharacter** (const char c)\
 char **getPrintableCharacter** (void) const\

Public Member Functions inherited from **SoButtonEvent** **SoButtonEvent** (void)\
 virtual **~SoButtonEvent** ()\
 void **setState** (**State** state)\
 **State** **getState** (void) const\

Public Member Functions inherited from **SoEvent** **SoEvent** (void)\
 virtual **~SoEvent** ()\
 SbBool **isOfType** (**SoType** type) const\
 void **setTime** (const **SbTime** t)\
 **SbTime** **getTime** (void) const\
 void **setPosition** (const **SbVec2s** &p)\
 const **SbVec2s** & **getPosition** (void) const\
 const **SbVec2s** & **getPosition** (const **SbViewportRegion** &vpRgn) const\
 const **SbVec2f** & **getNormalizedPosition** (const **SbViewportRegion** &vpRgn) const\
 void **setShiftDown** (SbBool isDown)\
 SbBool **wasShiftDown** (void) const\
 void **setCtrlDown** (SbBool isDown)\
 SbBool **wasCtrlDown** (void) const\
 void **setAltDown** (SbBool isDown)\
 SbBool **wasAltDown** (void) const\

### Static Public Member Functions

static **SoType** **getClassTypeId** (void)\
 static void **initClass** (void)\
 static SbBool **isKeyPressEvent** (const **SoEvent** \*e, **Key** whichKey)\
 static SbBool **isKeyReleaseEvent** (const **SoEvent** \*e, **Key** whichKey)\
 static SbBool **enumToString** (**Key** enumval, **SbString** &stringrep)\

Static Public Member Functions inherited from **SoButtonEvent** static **SoType** **getClassTypeId** (void)\
 static void **initClass** (void)\
 static SbBool **enumToString** (**State** enumval, **SbString** &stringrep)\

Static Public Member Functions inherited from **SoEvent** static **SoType** **getClassTypeId** (void)\
 static void **initClass** (void)\

## Detailed Description

The **SoKeyboardEvent** class contains information about keyboard interaction.

When the user presses any keys on the keyboard, these will be translated from a system specific event into a Coin event and sent to the scene graph by using instances of this class.

**See also**

**SoEvent**, **SoButtonEvent**, **SoMouseButtonEvent**, **SoSpaceballButtonEvent**

**SoEventCallback**, **SoHandleEventAction**

## Member Enumeration Documentation

### enum SoKeyboardEvent::Key

This enum contains all keys detected by Coin.

## Constructor & Destructor Documentation

### SoKeyboardEvent::SoKeyboardEvent (void )

Constructor.

### SoKeyboardEvent::~SoKeyboardEvent () \[virtual\]

Destructor.

## Member Function Documentation

### SoType SoKeyboardEvent::getClassTypeId (void ) \[static\]

This static method returns the **SoType** object associated with objects of this class.

### SoType SoKeyboardEvent::getTypeId (void ) const \[virtual\]

Returns the type identification of an object derived from a class inheriting **SoEvent**. This is used for runtime type checking and "downward" casting.

Reimplemented from **SoButtonEvent**.

### void SoKeyboardEvent::initClass (void ) \[static\]

Initialize the type information data.

### void SoKeyboardEvent::setKey (SoKeyboardEvent::Key keyarg)

Set the value of the key which the user interacted with.

This method is used from the window specific device classes when translating events to the generic Coin library.

**See also**

**getKey()**

### SoKeyboardEvent::Key SoKeyboardEvent::getKey (void ) const

Returns the value of the key which was pressed or released.

Coin adds a new key value called UNDEFINED. This is needed to support GUI toolkits where it is not possible to find exactly which key is pressed, and/or to support non-US keyboards. The Open Inventor design for this class is flawed, since it assumes everybody uses a US keyboard. We recommend using **getPrintableCharacter()** to find which key is pressed/released, at least for printable non-alphanumerical characters.

**See also**

**getPrintableCharacter()**, **getState()**

**wasShiftDown()**, **wasCtrlDown()**, **wasAltDown()**, **getPosition()**, **getTime()**

### void SoKeyboardEvent::setPrintableCharacter (const char c)

Sets the printable character for this keyboard event. If this method is not called when creating an event, **getPrintableCharacter()** will convert the **SoKeyboardEvent::Key** value into a printable character. This conversion does not work on non-US keyboards, so we recommend that you set the printable character using this method instead.

This printable character is cleared each time **setKey()** is called.

This method is an extension versus the Open Inventor API.

**See also**

**getPrintableCharacter()**

### char SoKeyboardEvent::getPrintableCharacter (void ) const

Return ASCII value which would be generated by the key and modifier combination.

NB! If **setPrintableCharacter()** hasn't been called, this function does not always work as expected, particularly not on non-US keyboards. The Coin GUI toolkits (SoGtk/SoQt/SoWin/SoXt/Sc21) will set the printable character correctly.

**See also**

**getKey()**, **wasShiftDown()**, **wasCtrlDown()**, **wasAltDown()**, **setPrintableCharacter()**

### SbBool SoKeyboardEvent::isKeyPressEvent (const SoEvent \* e, SoKeyboardEvent::Key whichKey) \[static\]

Convenience method for quickly checking if the given event is a key press on the given key, whichKey.

**See also**

**isKeyReleaseEvent()**, **isOfType()**, **getKey()**, **getState()**

### SbBool SoKeyboardEvent::isKeyReleaseEvent (const SoEvent \* e, SoKeyboardEvent::Key whichKey) \[static\]

Convenience method for quickly checking if the given event is a key release of the given key, whichKey.

**See also**

**isKeyPressEvent()**, **isOfType()**, **getKey()**, **getState()**

### SbBool SoKeyboardEvent::enumToString (Key enumval, SbString & stringrep) \[static\]

Converts from an enum value of type **SoKeyboardEvent::State** to a string containing the enum symbol.

This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.\
 **Since**

Coin 3.0

## Author

Generated automatically by Doxygen for Coin from the source code.
