Repository: flutter
Issue: Hardware keyboard handlers are invoked when TextField keyboardType is set to number, phone, dateTime etc. on mobile device.
Labels: a: text input,framework,engine,has reproducible steps,P3,team-design,triaged-design,found in release: 3.16,found in release: 3.20

### Steps to reproduce

Running the below code will suffice.

Tested on OnePlus Nord 2T (Android 13), Samsung Galaxy Tab S6 (Android 12), Samsung Galaxy Tab Active 2 (Android 9) using both Gboard and the in-built keyboards.

### Expected results

If the keyboardType is set to `TextInputType.text` or `TextInputType.datetime` or `TextInputType.name` or any **text-forward** type, the hardware keyboard listener doesn't get invoked. The other keyboard types should exhibit the same behaviour.

### Actual results

When the keyboardType is set to `TextInputType.number` or `TextInputType.phone` or any **number-forward** type, the hardware keyboard listener is invoked on the digit buttons, and if it returns true, the input is not propagated. This is easily worked around, but the behaviour with the different keyboard types is not consistent, and will cause time wasting debug sessions.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    ServicesBinding.instance.keyboard.addHandler(_handler);
  }

  bool _handler(event) {
    print(event);
    return true;
  }

  @override
  void dispose() {
    ServicesBinding.instance.keyboard.removeHandler(_handler);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Keyboard Bug',
      home: Scaffold(
        body: Center(
          child: SizedBox(
            width: 200,
            child: TextField(
              keyboardType: TextInputType.number,
            ),
          ),
        ),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.16.9, on macOS 13.6.3 22G436 darwin-x64, locale en-GB)
    • Flutter version 3.16.9 on channel stable at /Users/jasonelder/Documents/Flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41456452f2 (8 days ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/jasonelder/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version unknown)
    • Android Studio at /Applications/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (3 available)            
    • CPH2399 (mobile) • B6VWFUB6DQHQ6HTC • android-arm64  • Android 13 (API 33)
    • macOS (desktop)  • macos            • darwin-x64     • macOS 13.6.3 22G436 darwin-x64
    • Chrome (web)     • chrome           • web-javascript • Google Chrome 121.0.6167.139

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

```

</details>