hpoul / ctrl-alt-foo

Keyboard library to make keyboard events in Dart a pleasure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ctrl Alt Foo

Build Status

Make it easy to listen for keyboard shortcuts / accelator keys.

Usage

This is an early preview release and the syntax is not settled. Please add issues in the tracker if you have suggestions.

import 'package:ctrl_alt_foo/keys.dart';

Keys.shortcuts({
  'Esc':          (){ _hideMenu(); _hideDialog(); },
  'Ctrl+N':       ()=> new NewProjectDialog(this).open(),
  'Ctrl+O, ⌘+O':  ()=> new OpenDialog(this).open(),
  'Ctrl+Shift+H': ()=> toggleCode()
});

There are also some helper methods for creating keyboard events:

import 'package:ctrl_alt_foo/helpers.dart';

typeIn('TEXT'); // will generate a keyup

hitEnter();
hitEscape();

arrowUp(); // optionally supply the number of time to arrow up
arrowDown();

type('A'); // type a single character
typeCtrl('A'); // type Ctrl+A
typeCtrlShift('A'); // type Ctrl+Shift+A

LICENSE

This code is licensed under the MIT license. See LICENSE for more information.

About

Keyboard library to make keyboard events in Dart a pleasure.

License:Other


Languages

Language:Dart 96.4%Language:Shell 3.6%