super_keyboard_layout 0.9.0-dev.4 super_keyboard_layout: ^0.9.0-dev.4 copied to clipboard
Keyboard layout mapping for Flutter. Map between physical and logical keys according to current keyboard layout and provides notification on layout changes.
Keyboard layout mapping for Flutter #
Features #
- Supports macOS, Windows and Linux
- Allows mapping between physical keys, logical keys and platform specific key codes according to current keyboard layout.
- Notification for keyboard layout changes.
Getting started #
super_keyboard_layout
uses Rust internally to implement low-level platform specific functionality.
If you don't have Rust installed, the plugin will automatically download precompiled binaries for target platform.
If you want to have the Rust code compiled from source instead, you can install Rust through rustup. The presence of rustup will be detected during build automatically.
For macOS or Linux, execute the following command in Terminal.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
For Windows, you can use the Rust Installer.
In case you have Rust already installed, make sure to update it to latest version:
rustup update
That is it. The build integration will automatically install required Rust targets and other dependencies. This also means that first build might take a little bit longer.
Usage #
import 'package:super_keyboard_layout/super_keyboard_layout.dart';
void main() async {
final manager = await KeyboardLayoutManager.instance();
if (manager.supported) {
// Running on supported platform
manager.onLayoutChanged.addListener(() {
// Keyboard layout changed
print('Keyboard layout changed');
});
}
final layout = manager.currentLayout;
// Getting logical key for physical key 1 with shift for current layout
final logicalKey = layout.getLogicalKeyForPhysicalKey(PhysicalKeyboardKey.digit1, shift: true);
// Getting physical key for logical key
final physicalKey = layout.getPhysicalKeyForLogicalKey(LogicalKeyboardKey.keyA);
// Getting platform spcific key code for either logical or physical key
final playformCode = layout.getPlatformKeyCode(PhysicalKeyboardKey.digit1);
}
Running the example #
Example project is available at super_keyboard_layout/example
.
flutter pub global activate melos # if you don't have melos already installed
git clone https://github.com/superlistapp/super_native_extensions.git
cd super_native_extensions
melos bootstrap
After this you can open the folder in VSCode and run the super_keyboard_layout
launcher configuration.
TODO(knopp): Add Intellij launcher configuration
Additional information #
This plugin is in a very early stages of development and quite experimental.
PRs and bug reports are welcome!