Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

mapping jk to esc

This one is pretty simple. Assuming you are using some sort of Insert Mode:

#![allow(unused)]
fn main() {
mod duat_kak {
    use duat::{prelude::{*, mode::KeyEvent}};
    #[derive(Clone)]
    pub struct Insert;
    impl Mode<Ui> for Insert {
        type Widget = File;
        fn send_key(&mut self, _: &mut Pass, _: KeyEvent, _: Handle<File>) {
            todo!();
        }
    }
}
use duat::prelude::*;
setup_duat!(setup);
fn setup() {
// Or vim::Insert, or helix::Insert, when those come out.
map::<duat_kak::Insert>("jk", "<Esc>");
}
}

This won't print anything to the screen while you're typing, making it seem like the j key has a bit of delay. If you wish to print 'j' to the screen, use this:

#![allow(unused)]
fn main() {
mod duat_kak {
    use duat::{prelude::{*, mode::KeyEvent}};
    #[derive(Clone)]
    pub struct Insert;
    impl Mode<Ui> for Insert {
        type Widget = File;
        fn send_key(&mut self, _: &mut Pass, _: KeyEvent, _: Handle<File>) {
            todo!();
        }
    }
}
use duat::prelude::*;
setup_duat!(setup);
fn setup() {
alias::<duat_kak::Insert>("jk", "<Esc>");
}
}

Additionally, if you want to write to the file on jk as well, you can do this:

#![allow(unused)]
fn main() {
mod duat_kak {
    use duat::{prelude::{*, mode::KeyEvent}};
    #[derive(Clone)]
    pub struct Insert;
    impl Mode<Ui> for Insert {
        type Widget = File;
        fn send_key(&mut self, _: &mut Pass, _: KeyEvent, _: Handle<File>) {
            todo!();
        }
    }
}
use duat::prelude::*;
setup_duat!(setup);
fn setup() {
alias::<duat_kak::Insert>("jk", "<Esc>:w<Enter>");
}
}

If you want to, you can also make this happen on the PromptLine, i.e., while writing commands and searches:

#![allow(unused)]
fn main() {
use duat::prelude::*;
setup_duat!(setup);
fn setup() {
alias::<Prompt<Ui>>("jk", "<Esc>");
}
}