You have to connect ground between the modules. Without common ground the logic level of signal can't be measured. While both boards were powered over USB from the same laptop the boards had common ground.
read returns -1 if nothing is available so check if some character was received:
void loop() {
if (Serial1.available()) {
Keyboard.write(Serial1.read());
}
}
btw: The MKR can emulate a keyboard too with the KwyboardKeyboard library.