A minimal Teensy 4 Sketch in the Arduino IDE consisting of using the function:

Keyboard.Print("Hello");

...yields an error message of
"....Multiple libraries were found for "Keyboard.h"...."
and
'Keyboard' was not declared in this scope

Changing the Arduino IDE menu "Tools/USB Type:" from "Serial" to "Keyboard"

cures the problem and results in a successful compile.

What exactly does setting this menu item do to the code compilation? The reason I ask is that I get the same errors when attempting a compile of the same code in platformio/vscode and I would like to resolve it there as well.