Class DKey

Inherits from:
Object
Conforms to:
DParsable, DTextable
Declared in:
DKey.h

Class Hierarchy

    Object
      |
      +---DKey

Class Description

The DKey class implements methods for storing keyboard keys.

Example:
#include <stdio.h>
#include "ofc/DKey.h"

int main(int argc, char *argv[])
{
  DKey  *key1 = [DKey alloc];
  DKey  *key2 = [DKey new  ];
  DText *str;

  [key1 init :DKEY_ESCAPE];            // Init with the escape key

                                       // Check for control key
  printf("Key1 %s a control key.\n", ([key1 isCtrlKey] ? "is" : "is not"));

  str = [key1 toText];                 // Convert the key to string description
  printf("Key1 description: %s.\n", [str cstring]);
  [str free];


  [key2 set :DKEY_DELETE|DKEY_MOD_CTRL|DKEY_MOD_ALT]; // Set the key to Ctrl-Alt-Del

  printf("Key2 %s a control key.\n", ([key2 isCtrlKey ] ? "is" : "is not"));
  printf("Key2 %s a shift key.\n",   ([key2 isShiftKey] ? "is" : "is not"));
  printf("Key2 %s a alt key.\n",     ([key2 isAltKey  ] ? "is" : "is not"));

  str = [key2 toText];                 // Convert the key to string description
  printf("Key2 description:%s.\n", [str cstring]);
  [str free];

  [key1 free];                         // Cleanup
  [key2 free];

  return 0;
}
Last modified:
05-Aug-2008 (DKey.h)

Instance Variables

private int _code
the keyboard code

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0