MCPcopy Create free account
hub / github.com/TyberiusPrime/KeyToKey / process_keys

Method process_keys

src/premade.rs:240–276  ·  view source on GitHub ↗
(&mut self, events: &mut Vec<(Event, EventStatus)>, output: &mut T)

Source from the content-addressed store, hash-verified

238pub struct CopyPaste {}
239impl<T: USBKeyOut> ProcessKeys<T> for CopyPaste {
240 fn process_keys(&mut self, events: &mut Vec<(Event, EventStatus)>, output: &mut T) ->HandlerResult {
241 //step 0: on key release, remove all prior key presses.
242 for (e, status) in iter_unhandled_mut(events) {
243 match e {
244 Event::KeyPress(kc) => {
245 if kc.keycode == KeyCode::Copy.into() {
246 output.send_keys(&[KeyCode::LCtrl, KeyCode::Insert]);
247 output.send_empty();
248 *status = EventStatus::Handled;
249 }
250 if kc.keycode == KeyCode::Paste.into() {
251 output.send_keys(&[KeyCode::LShift, KeyCode::Insert]);
252 output.send_empty();
253 *status = EventStatus::Handled;
254 }
255 if kc.keycode == KeyCode::Cut.into() {
256 output.send_keys(&[KeyCode::LShift, KeyCode::Delete]);
257 output.send_empty();
258 *status = EventStatus::Handled;
259 }
260 }
261 Event::KeyRelease(kc) => {
262 if kc.keycode == KeyCode::Copy.into() {
263 *status = EventStatus::Handled;
264 }
265 if kc.keycode == KeyCode::Paste.into() {
266 *status = EventStatus::Handled;
267 }
268 if kc.keycode == KeyCode::Cut.into() {
269 *status = EventStatus::Handled;
270 }
271 }
272 _ => {}
273 }
274 }
275 HandlerResult::NoOp
276 }
277}
278
279

Callers 1

handle_keysMethod · 0.45

Calls 3

iter_unhandled_mutFunction · 0.85
send_keysMethod · 0.80
send_emptyMethod · 0.80

Tested by

no test coverage detected