         }
         
         let pin = (state?.pin ?? "").uppercased()
+        
+        // Disallow entering non-matching characters if necessary
+        guard state?.allowAllCharacters == true || newText == pin.substring(to: newText.characters.count) else {
+            return false
+        }
+        
         let showsHint = state?.showsHint == true
         
         for (i, button) in buttons.enumerated() {

    }
    
    func commonInit() {
        if pin != nil || allowsBackspace != nil || showsHint != nil {
            state = State(pin: pin, allowsBackspace: allowsBackspace, showsHint: showsHint)
        }
        
        backgroundColor = .clear

        public var pin: String?
        public var allowsBackspace: Bool
        public var showsHint: Bool
        public var allowAllCharacters: Bool
        
        public init(pin: String?,
                    allowsBackspace: Bool = true,
                    showsHint: Bool = true,
                    allowAllCharacters: Bool = true) {
            self.pin = pin
            self.allowsBackspace = allowsBackspace
            self.showsHint = showsHint
            self.allowAllCharacters = allowAllCharacters
        }
    }
    
