keyboard.h header is not working

Hello, everyone, I'm new to this community I tried to change my Arduino 16u2 to mega 2560. I saw that to use keyboard functions in Arduino 16u2 we have to use this firmware change everything is working fine but getting this error. I also installed every library required
Arduino: 1.8.12 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from C:\Users\sys\Documents\Arduino\KeyboardLogout\KeyboardLogout.ino:5:0:

C:\Users\sys\Documents\Arduino\libraries\Keyboard\src/Keyboard.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]

#warning "Using legacy HID core (non pluggable)"

^~~~~~~

C:\Users\sys\Documents\Arduino\KeyboardLogout\KeyboardLogout.ino: In function 'void typeKey(int)':

KeyboardLogout:9:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(key);

^~~~~~~~

C:\Users\sys\Documents\Arduino\KeyboardLogout\KeyboardLogout.ino: In function 'void setup()':

KeyboardLogout:18:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.begin();

^~~~~~~~

KeyboardLogout:25:18: error: 'KEY_LEFT_GUI' was not declared in this scope

Keyboard.press(KEY_LEFT_GUI);

^~~~~~~~~~~~

KeyboardLogout:35:11: error: 'KEY_RETURN' was not declared in this scope

typeKey(KEY_RETURN);

^~~~~~~~~~

Multiple libraries were found for "Keyboard.h"
Used: C:\Users\sys\Documents\Arduino\libraries\Keyboard
Not used: C:\Users\sys\Documents\Arduino\libraries\BlueFairy
Not used: C:\Users\sys\Documents\Arduino\libraries\Keyboard-master
Not used: E:\hacks\arduino hack\Arduino\libraries\Keyboard
exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Never tried it but just changing the 16U2 firmware does not give the main processor (2560) additional capabilities like HID. The HID libraries require a board with native USB (e.g. Leonardo, Micro and a number of others).

I think that you need to use the normal Serial.write/Serial.print commands, but I'm not sure.