SwiftUIKeyPress - a package to make up for the lack of keyboard input in SwiftUI

Overview

SwiftUIKeyPress

SwiftUIKeyPress is a package to make up for the lack of keyboard input in SwiftUI.

How to use?

There are three ways that you can implement SwiftUIPress

First:

struct ContentView: View
    @State var keys = [UIKey]()

    var body: some View {
        Text(keys.map(\.characters).reduce("", +))
            .padding()
            .onKeyPress($keys)
    }
}

Second:

struct ContentView: View
    @State var keys = [UIKey]()

    var body: some View {
        Text(keys.map(\.characters).reduce("", +))
            .padding()
            .onKeyPress { keys in
                self.keys = keys
            }
    }
}

Third:

struct ContentView: View
    @State var keys = [UIKey]()

    var body: some View {
        Text(keys.map(\.characters).reduce("", +))
            .padding()
            .onKeyUpdate { keys in
                self.keys = keys
            }
    }
}

A Tips

You only can use 1 SwiftUIKeyPress modifier on every one view. The others will not work.

And on MacOS, UIKey is a string value.

You might also like...
QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard
QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard

QMKagent QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard Features System volume indicator using top row (Esc t

Best way to dismiss Keyboard in a View Controller iOS (Swift)
Best way to dismiss Keyboard in a View Controller iOS (Swift)

Best way to dismiss Keyboard in a View Controller iOS (Swift) First way: Implement UITextFieldDelegate’s textFieldShouldReturn method and dismiss curr

Showing / dismissing keyboard animation in simple UIViewController category.
Showing / dismissing keyboard animation in simple UIViewController category.

RSKKeyboardAnimationObserver Easy way to handle iOS keyboard showing/dismissing. Introduction Working with iOS keyboard demands a lot of duplicated co

Objective-C library for tracking keyboard in iOS apps.
Objective-C library for tracking keyboard in iOS apps.

NgKeyboardTracker Objective-c library for tracking keyboard in iOS apps. Adding to your project If you are using CocoaPods, add to your Podfile: pod '

A simple keyboard to use with numbers and, optionally, a decimal point.
A simple keyboard to use with numbers and, optionally, a decimal point.

MMNumberKeyboard A simple keyboard to use with numbers and, optionally, a decimal point. Installation From CocoaPods CocoaPods is a dependency manager

For less complicated keyboard event handling.

KeyboardObserver For less complicated keyboard event handling. Features Less complicated keyboard event handling. Do not use Notification , but event

A drop-in universal solution for moving text fields out of the way of the keyboard in iOS

TPKeyboardAvoiding A drop-in universal solution for moving text fields out of the way of the keyboard in iOS. Introduction There are a hundred and one

Emoji Keyboard SDK (iOS)
Emoji Keyboard SDK (iOS)

Makemoji SDK Makemoji is a free emoji keyboard for mobile apps. By installing our keyboard SDK every user of your app will instantly have access to ne

A Chinese keyboard for iOS that helps Chinese language learners remember tones.
A Chinese keyboard for iOS that helps Chinese language learners remember tones.

ToneBoard ToneBoard is a Chinese keyboard for iOS that requires you to enter the correct tones while typing simplified Chinese with Pinyin. It is avai

Owner
Underthestars-zhy
iOS software developer
Underthestars-zhy
Automatic keyboard/input source switching for OSX

Autokbisw - Automatic keyboard input source switcher Motivation This small utility was born out of frustation after a mob programming sesssion. The se

Ole Hüter 67 Jan 6, 2023
KeyboardMan helps you to make keyboard animation.

KeyboardMan We may need keyboard infomation from keyboard notifications to do animation. However, the approach is complicated and easy to make mistake

null 353 Apr 19, 2022
⌨️A Combine-based way to observe and adjust for Keyboard notifications in SwiftUI

⌨️ Keyboard Observing A Combine-based solution for observing and avoiding the keyboard in SwiftUI. Table of Contents About Requirements Installation C

Nick Fox 440 Jan 5, 2023
IHKeyboardAvoiding is an elegant solution for keeping any UIView visible when the keyboard is being shown - no UIScrollView required!

IHKeyboardAvoiding An elegant solution for keeping any UIView visible when the keyboard is being shown Requirements IHKeyboardAvoiding Version Objecti

Idle Hands Apps 1.4k Dec 14, 2022
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.

IQKeyboardManager While developing iOS apps, we often run into issues where the iPhone keyboard slides up and covers the UITextField/UITextView. IQKey

Mohd Iftekhar Qurashi 15.9k Jan 8, 2023
Codeless manager to hide keyboard by tapping on views for iOS written in Swift

KeyboardHideManager KeyboardHideManager - codeless manager to hide keyboard by tapping on views for iOS written in Swift. Structure Features Requireme

Bondar Yaroslav 55 Oct 19, 2022
⌨️ Add user-customizable global keyboard shortcuts to your macOS app in minutes

This package lets you add support for user-customizable global keyboard shortcuts to your macOS app in minutes. It's fully sandbox and Mac App Store c

Sindre Sorhus 1.1k Dec 29, 2022
Swift UIKit keyboard manager for iOS apps.

Typist Typist is a small, drop-in Swift UIKit keyboard manager for iOS apps. It helps you manage keyboard's screen presence and behavior without notif

Toto Tvalavadze 1.1k Dec 10, 2022
Suppress mouse & keyboard events on MacOSX. Baby-proof my Mac!

Suppress mouse & keyboard events on MacOSX Catches all events (mouse, keyboard, everything), and either consumes them (locked state) or passes them th

Albert Zeyer 6 Oct 21, 2022
KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit 900 Jan 9, 2023