zeba_academy_keyboard_shortcuts 1.0.0
zeba_academy_keyboard_shortcuts: ^1.0.0 copied to clipboard
Desktop keyboard shortcut manager for Flutter.
⌨️ Zeba Academy Keyboard Shortcuts #
A lightweight, customizable, and production-ready Flutter package for managing keyboard shortcuts across desktop and web applications.
zeba_academy_keyboard_shortcuts makes it easy to register keyboard shortcuts, support multiple key combinations, organize shortcuts through a centralized manager, and build responsive desktop experiences with clean and maintainable APIs.
✨ Features #
- ✅ Register custom keyboard shortcuts
- ✅ Support multiple key combinations
- ✅ Global shortcut manager
- ✅ Enable or disable shortcuts dynamically
- ✅ Desktop-first design
- ✅ Windows support
- ✅ macOS support
- ✅ Linux support
- ✅ Flutter Web keyboard support
- ✅ Lightweight implementation
- ✅ No third-party dependencies
📦 Installation #
Add the package to your pubspec.yaml.
dependencies:
zeba_academy_keyboard_shortcuts: ^1.0.0
Then run:
flutter pub get
Import the package:
import 'package:zeba_academy_keyboard_shortcuts/zeba_academy_keyboard_shortcuts.dart';
🚀 Quick Start #
Register a keyboard shortcut before running your application.
ShortcutManager.instance.register(
KeyboardShortcut(
keys: const ShortcutKeys(
ctrl: true,
key: LogicalKeyboardKey.keyS,
),
callback: () {
debugPrint("Saved!");
},
),
);
Wrap your application with ShortcutScope.
MaterialApp(
home: ShortcutScope(
child: HomePage(),
),
);
📖 Basic Example #
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zeba_academy_keyboard_shortcuts/zeba_academy_keyboard_shortcuts.dart';
void main() {
ShortcutManager.instance.register(
KeyboardShortcut(
keys: const ShortcutKeys(
ctrl: true,
key: LogicalKeyboardKey.keyS,
),
callback: () {
debugPrint("Save pressed");
},
),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: ShortcutScope(
child: Scaffold(
appBar: AppBar(
title: const Text("Keyboard Shortcuts"),
),
body: const Center(
child: Text(
"Press Ctrl + S",
),
),
),
),
);
}
}
⌨️ Multiple Shortcut Combinations #
ShortcutManager.instance.register(
KeyboardShortcut(
keys: const ShortcutKeys(
ctrl: true,
shift: true,
key: LogicalKeyboardKey.keyP,
),
callback: () {
print("Print");
},
),
);
ShortcutManager.instance.register(
KeyboardShortcut(
keys: const ShortcutKeys(
ctrl: true,
alt: true,
key: LogicalKeyboardKey.keyD,
),
callback: () {
print("Developer Mode");
},
),
);
🖥️ Built-in Desktop Shortcuts #
The package includes commonly used desktop shortcuts.
DesktopShortcuts.save
DesktopShortcuts.copy
DesktopShortcuts.paste
DesktopShortcuts.cut
DesktopShortcuts.undo
DesktopShortcuts.redo
DesktopShortcuts.selectAll
DesktopShortcuts.find
Example:
ShortcutManager.instance.register(
KeyboardShortcut(
keys: DesktopShortcuts.copy,
callback: () {
print("Copy");
},
),
);
📚 API Overview #
ShortcutKeys #
Defines a keyboard shortcut.
const ShortcutKeys(
ctrl: true,
shift: true,
alt: false,
meta: false,
key: LogicalKeyboardKey.keyS,
);
KeyboardShortcut #
Represents a keyboard shortcut with a callback.
KeyboardShortcut(
keys: shortcut,
callback: () {},
);
ShortcutManager #
Register shortcuts.
ShortcutManager.instance.register(...);
Remove shortcuts.
ShortcutManager.instance.unregister(...);
Remove all shortcuts.
ShortcutManager.instance.clear();
ShortcutScope #
Wrap your widget tree.
ShortcutScope(
child: HomePage(),
)
ShortcutUtils #
Check modifier keys.
ShortcutUtils.isCtrl();
ShortcutUtils.isShift();
ShortcutUtils.isAlt();
ShortcutUtils.isMeta();
📁 Package Structure #
lib/
│
├── src/
│ ├── keyboard_shortcut.dart
│ ├── shortcut_controller.dart
│ ├── shortcut_event.dart
│ ├── shortcut_keys.dart
│ ├── shortcut_manager.dart
│ ├── shortcut_scope.dart
│ ├── shortcut_utils.dart
│ └── desktop_shortcuts.dart
│
├── keyboard_shortcuts.dart
└── zeba_academy_keyboard_shortcuts.dart
💻 Platform Support #
| Platform | Supported |
|---|---|
| Android | ✅ |
| iOS | ✅ |
| Windows | ✅ |
| macOS | ✅ |
| Linux | ✅ |
| Web | ✅ |
🚀 Roadmap #
Future versions may include:
- Shortcut groups
- Context-aware shortcuts
- Shortcut rebinding
- Widget-level shortcut registration
- Shortcut persistence
- Conflict detection
- Key sequence support
- Global hotkeys
- Command palette integration
- Visual shortcut overlay
🤝 Contributing #
Contributions, bug reports, feature requests, and pull requests are always welcome.
If you find this package useful, consider giving it a ⭐ on GitHub.
📄 License #
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
See the LICENSE file for complete license information.
👨💻 About Me #
✨ I'm Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects.
You can learn more about me and my work:
🌐 Website: https://sufyanism.com
💼 LinkedIn: https://www.linkedin.com/in/sufyanism
🎓 Your All-in-One Learning Hub #
🚀 Explore courses and resources in coding, technology, Flutter, and software development.
Zeba Academy #
🌍 Main Website
https://zeba.academy
💻 Learning Platform
https://code.zeba.academy
📺 YouTube Channel
https://www.youtube.com/@zeba.academy
📸 Instagram
https://www.instagram.com/zeba.academy/
Learn through practical projects, real-world examples, and hands-on tutorials designed for developers of all skill levels.
❤️ Support #
If this package helped you, please consider:
- ⭐ Star the repository
- 👍 Like and share
- 🐛 Report issues
- 💡 Suggest new features
- 🤝 Contribute to the project
Your support helps improve open-source software for everyone.
Made with ❤️ by Sufyan bin Uzayr
Happy Coding! 🚀