it doesn't detect the keypresses:

import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:just_audio/just_audio.dart';

import 'package:flutter/services.dart';

import 'package:http/http.dart' as http;

Future<void> main() async {
  // Ensure that plugin services are initialized so that `availableCameras()`
  // can be called before `runApp()`
  WidgetsFlutterBinding.ensureInitialized();

  // Obtain a list of the available cameras on the device.
  final cameras = await availableCameras();

  // Get a specific camera from the list of available cameras.
  final firstCamera = cameras.first;

  runApp(
    MaterialApp(
      theme: ThemeData.dark(),
      home: TakePictureScreen(
        // Pass the appropriate camera to the TakePictureScreen widget.
        camera: firstCamera,
      ),
    ),
  );
}

// A screen that allows users to take a picture using a given camera.
class TakePictureScreen extends StatefulWidget {
  const TakePictureScreen({
    super.key,
    required this.camera,
  });

  final CameraDescription camera;

  @override
  TakePictureScreenState createState() => TakePictureScreenState();
}

class TakePictureScreenState extends State<TakePictureScreen> {
  late CameraController _controller;
  late Future<void> _initializeControllerFuture;

  @override
  void initState() {
    super.initState();
    // To display the current output from the Camera,
    // create a CameraController.
    _controller = CameraController(
      // Get a specific camera from the list of available cameras.
      widget.camera,
      // Define the resolution to use.
      ResolutionPreset.medium,
    );

    // Next, initialize the controller. This returns a Future.
    _initializeControllerFuture = _controller.initialize();
  }

  Future<void> captureAndSendImage() async {
    // Your existing code here...
    try {
      await _initializeControllerFuture;

      final image = await _controller.takePicture();

      if (!mounted) return;

      // Send the image to the server
      var request = http.MultipartRequest(
          'POST', Uri.parse('http://localhost:8000/api/phone/camera'));
      request.files.add(await http.MultipartFile.fromPath('file', image.path));
      request.fields['direction'] = "In";
      var res = await request.send();
      var response = await http.Response.fromStream(res);

      if (response.statusCode == 200) {
        // If the server returns a 200 OK response, then proceed
        var responseData = jsonDecode(response.body);
        var audioBase64 = responseData[1]['audio'];

        // Decode the Base64 string to bytes
        var audioBytes = base64Decode(audioBase64);

        // Save the audio to a temporary file
        var directory = await getApplicationDocumentsDirectory();
        var audioPath = '${directory.path}/temp.mp3';
        var audioFile = File(audioPath);
        await audioFile.writeAsBytes(audioBytes);

        // Load the audio file
        var player = AudioPlayer();
        await player.setUrl(audioPath);

        // Play the audio file
        player.play();
      } else {
        // If the server returns an error response,
        // then print the status code.
        print('Failed to upload image. Status code: ${response.statusCode}.');
      }
    } catch (e) {
      print(e);
    }
  }

  @override
  void dispose() {
    // Dispose of the controller when the widget is disposed.
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return KeyboardListener(
      focusNode: FocusNode(),
      autofocus: true,
      onKeyEvent: (KeyEvent event) {
        if (event is KeyDownEvent) {
          print(event.logicalKey.keyLabel);
          if (event.logicalKey.keyLabel == 'Audio Volume Up') {
            captureAndSendImage();
          }
          if (event.logicalKey.keyLabel == 'Audio Volume Down') {
            captureAndSendImage();
          }
        }
      },
      child: Scaffold(
        appBar: AppBar(title: const Text('Take a picture')),
        body: FutureBuilder<void>(
          future: _initializeControllerFuture,
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              return CameraPreview(_controller);
            } else {
              return const Center(child: CircularProgressIndicator());
            }
          },
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: captureAndSendImage,
          child: const Icon(Icons.camera_alt),
        ),
      ),
    );
  }
}