I wanted to keypost some basic programs into the apple 3 driver but the emu.keypost("\"") wouldn't give me a proper quote.

It's a pretty easy fix, just change the PORT_CHAR to "@" for KEYCODE_2, because the \" is also on KEYCODE_QUOTE, so the keypost gets the first one while it searches, finding the 2 key instead of the quote key.

Code
diff --git a/src/mame/drivers/apple3.cpp b/src/mame/drivers/apple3.cpp
index ecaa1453d0..e429ecf878 100644
--- a/src/mame/drivers/apple3.cpp
+++ b/src/mame/drivers/apple3.cpp
@@ -215,7 +215,7 @@ static INPUT_PORTS_START( apple3 )
        PORT_START("X0")
        PORT_BIT(0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc")      PORT_CODE(KEYCODE_ESC)      PORT_CHAR(27)
        PORT_BIT(0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1)      PORT_CHAR('1') PORT_CHAR('!')
-       PORT_BIT(0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2)  PORT_CHAR('2') PORT_CHAR('\"')
+       PORT_BIT(0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2)  PORT_CHAR('2') PORT_CHAR('@')
        PORT_BIT(0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3)  PORT_CHAR('3') PORT_CHAR('#')
        PORT_BIT(0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4)  PORT_CHAR('4') PORT_CHAR('$')
        PORT_BIT(0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5)  PORT_CHAR('5') PORT_CHAR('%')

also I thought it'd be cool to have a emu.keydump() to help see the keys, a simple two line addition to luaengine.cpp:

Code
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index df730b7019..89bba51324 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -8,6 +8,7 @@
 
 ***************************************************************************/
 
+#include <iostream>
 #include <thread>
 #include <lua.hpp>
 #include "emu.h"
@@ -805,6 +806,7 @@ void lua_engine::initialize()
        emu["romname"] = [this](){ return machine().basename(); };
        emu["softname"] = [this]() { return machine().options().software_name(); };
        emu["keypost"] = [this](const char *keys){ machine().ioport().natkeyboard().post_utf8(keys); };
+       emu["keydump"] = [this](){ machine().ioport().natkeyboard().dump(std::cout); };
        emu["time"] = [this](){ return machine().time().as_double(); };
        emu["start"] = [this](const char *driver) {
                        int i = driver_list::find(driver);