https://github.com/utmapp/visionkeyboardkit
Full sized keyboard for visionOS
https://github.com/utmapp/visionkeyboardkit
Last synced: 9 months ago
JSON representation
Full sized keyboard for visionOS
- Host: GitHub
- URL: https://github.com/utmapp/visionkeyboardkit
- Owner: utmapp
- License: apache-2.0
- Created: 2023-11-13T19:52:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-19T16:03:42.000Z (over 2 years ago)
- Last Synced: 2025-09-22T13:48:30.732Z (9 months ago)
- Language: Swift
- Size: 385 KB
- Stars: 36
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Vision Keyboard Kit
===================

## Features
* Full sized (104-keys) or 60% (no arrow/num keys) mode
* Support for multiple keyboard layouts
* PS/2 Set 1 scan code generation
* Multiple instances with independent event handlers
* Key down and key up events
## Usage
Declare `KeyboardWindowGroup` in your `Scene`:
```swift
import SwiftUI
import VisionKeyboardKit
@main
struct YourApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
KeyboardWindowGroup()
}
}
```
Open/close the keyboard window using `OpenWindowAction`/`DismissWindowAction` and receive events through `KeyboardEvent.publisher(for:)`:
```swift
import SwiftUI
import VisionKeyboardKit
struct ContentView: View {
@Environment(\.openWindow) private var openWindow
@Environment(\.dismissWindow) private var dismissWindow
@State private var isKeyboardShown: Bool = false
var body: some View {
Button {
if !isKeyboardShown {
openWindow(keyboardFor: .global)
} else {
dismissWindow(keyboardFor: .global)
}
} label: {
Text("Toggle Keyboard")
}.onReceive(KeyboardEvent.publisher(for: .global)) { event in
if case .keyboardDidAppear = event {
isKeyboardShown = true
} else if case .keyboardDidDisappear = event {
isKeyboardShown = false
} else {
print("Got event: \(event)")
}
}
}
}
```
If you need more than one keyboard with independent event publishers, just pass in any `Hashable` which serves as an identifier for the keyboard.
The returned `Publisher` can be used in the Combine framework for chained processing (such as debounce).