examples/component/print_key_press.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.

    #include<stddef.h>//forsize_t
    #include<algorithm>//formax
    #include<memory>//forallocator,shared_ptr
    #include<string>//forchar_traits,operator+,string,basic_string,to_string
    #include<utility>//formove
    #include<vector>//forvector

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forCatchEvent,Renderer
    #include"ftxui/component/event.hpp"//forEvent
    #include"ftxui/component/mouse.hpp"//forMouse,Mouse::Left,Mouse::Middle,Mouse::None,Mouse::Pressed,Mouse::Released,Mouse::Right,Mouse::WheelDown,Mouse::WheelUp
    #include"ftxui/component/screen_interactive.hpp"//forScreenInteractive
    #include"ftxui/dom/elements.hpp"//fortext,vbox,window,Element,Elements

    usingnamespaceftxui;

    std::stringCode(Eventevent){
    std::stringcodes;
    for(auto&it:event.input()){
    codes+=""+std::to_string((unsignedint)it);
    }
    returncodes;
    }

    intmain(){
    autoscreen=ScreenInteractive::TerminalOutput();

    std::vector<Event>keys;

    autoleft_column=Renderer([&]{
    Elementschildren={
    text("Codes"),
    separator(),
    };
    for(size_ti=std::max(0,(int)keys.size()-20);i<keys.size();++i){
    children.push_back(text(Code(keys[i])));
    }
    returnvbox(children);
    });

    autoright_column=Renderer([&]{
    Elementschildren={
    text("Event"),
    separator(),
    };
    for(size_ti=std::max(0,(int)keys.size()-20);i<keys.size();++i){
    children.push_back(text(keys[i].DebugString()));
    }
    returnvbox(children);
    });

    intsplit_size=40;
    autocomponent=ResizableSplitLeft(left_column,right_column,&split_size);
    component|=border;

    component|=CatchEvent([&](Eventevent){
    keys.push_back(event);
    returnfalse;
    });

    screen.Loop(component);
    }