paperlib icon indicating copy to clipboard operation
paperlib copied to clipboard

[Feature Request] Support more hotkeys

Open fkcptlst opened this issue 1 year ago • 5 comments

Describe your feature request ... 支持更多快捷键,比如delete删除、ctrl+f查找等。

fkcptlst avatar Jun 03 '23 12:06 fkcptlst

@charlieJ107 please investigate this issue. Let's first add delete. ctrl+f is unnecessary as we have a new command panel in 3.0.

Currently, in the hotkey tab of the preference view, we use multiple <select> to do the hotkey binding. It would be better to implement a new Vue component for this:

  • click this component to activate key-binding, and listen to any key pressing now.
  • record and show the user's keyboard pressing.
  • validate the hotkey
  • emit an event if it is a valid hotkey.

If the key-binding is activated, I think we should disable all other hotkeys registered in the menuService:

await PLMainAPI.menuService.disableAll()

You can just implement the functionality of this component and leave the style design to me if you don't know how to make it consistent with other UI styles.

GeoffreyChen777 avatar Jan 12 '24 11:01 GeoffreyChen777

Fixing with #364

charlieJ107 avatar Feb 01 '24 07:02 charlieJ107

Do we have a hotkey for saving metadata edits? It's tedious to click the "save" button with the mouse every time.

chen-yingfa avatar Mar 06 '24 07:03 chen-yingfa

Do we have a hotkey for saving metadata edits? It's tedious to click the "save" button with the mouse every time.

My understanding is the changes are saved in real time because we're using Realm to store metadata. The metadata will be saved and sync (if applicable) as soon as you make the change. @GeoffreyChen777 Would you mind confirm this?

charlieJ107 avatar Mar 06 '24 10:03 charlieJ107

@charlieJ107 He requests a hotkey to save the metadata and close the editing window.

Currently, the metadata will be updated once the user clicks the Save button.

@chen-yingfa I will add a hotkey 'cmd+s' for this in the next beta.

GeoffreyChen777 avatar Mar 06 '24 10:03 GeoffreyChen777

@igoogolx would you mind taking this issue as @charlieJ107 seems to be busy recently?

related PR #364

GeoffreyChen777 avatar Mar 19 '24 15:03 GeoffreyChen777

@igoogolx would you mind taking this issue as @charlieJ107 seems to be busy recently?

related PR #364

Sure. I will take it.

igoogolx avatar Mar 19 '24 16:03 igoogolx

@igoogolx would you mind taking this issue as @charlieJ107 seems to be busy recently? related PR #364

Sure. I will take it.

I'll make a catch-up commit on the #364 so you can directly start to develop new hotkeys settings feature

charlieJ107 avatar Mar 19 '24 16:03 charlieJ107

@igoogolx would you mind taking this issue as @charlieJ107 seems to be busy recently? related PR #364

Sure. I will take it.

I'll make a catch-up commit on the #364 so you can directly start to develop new hotkeys settings feature

Thanks.

igoogolx avatar Mar 20 '24 14:03 igoogolx

Could you plz grant me permission to push the code? I found that I don't have the permission. @GeoffreyChen777

igoogolx avatar Mar 20 '24 14:03 igoogolx

I have implemented most of the features. However, there are still some problems. You can pull my code from the branch to check the features. @GeoffreyChen777

  • There is a conflict with the global shortcuts. I mean that we can disable the menuService. However, there is no way to disable the globalShortcut from the render process now. I want to implement that. The problem is where we put the code. windowProcessManagementService?
  • What are the rules to validate the hotkey? Currently, I only check if it has three keys. https://github.com/Future-Scholars/paperlib/blob/b36abd30e53eeaeaee5ee8fb33074bcd05301805/app/renderer/ui/preference-view/components/hotkey-options.vue#L39

igoogolx avatar Mar 20 '24 15:03 igoogolx

@igoogolx

  1. About the rules:
  • we have three slots: modifier(ctrl/cmd), shift, A-Z...
  • if we use shift, we must use modifier. shift+key is invalid.
  • modifier+key is valid.
  • Some keys can be used without the modifier, such as Enter, Space, Backspace, F1-12. For others, Let's require a modifier mandatorily.
  1. About globalShortcut. Currently, we have only one globalShortcut: cmd+shift+i to open the Quick Reference plugin window. TBH, I think the design of the shortcut service is a bit messy.

Currently, we have two services for shortcuts:

  • PLMainAPI.menuService
  • PLAPI.shourtcutService

The first one is based on the Electron. The second one is based on the HTML.

In the menuService, we have a method disableAll. The reason is that, we need to disable the menu shortcuts in certain cases, such as in <input>.

However, these two services make shortcut management messier and messier and cause many bugs.

I have a proposal want to discuss with you: remove most shortcuts managed by the menuService. We use shourtcutService to manage most shortcuts.

shourtcutService has a method registerInInputField which makes it easy to handle shortcuts in <input>.

Looking forward to your comments.


About the shortcut component. It looks good. But I have a suggestion: when we click the input box, it would be better to remove the previous text and show press any key or something like that.

GeoffreyChen777 avatar Mar 20 '24 15:03 GeoffreyChen777

Agree with refactoring shortcutService. But I suggest that we do it in another PR. Here I will put the code about globalShortcut in shourtcutService. You can file a new issue about the refactoring and assign it to me. @GeoffreyChen777

igoogolx avatar Mar 21 '24 07:03 igoogolx

For the rules:

Can we simplify the rules? I suggest:

  • The length of keys must be 2 or 3.
  • Only shortcuts that start with Ctrl or Cmd, Alt or Option, or Shift are valid. @GeoffreyChen777

igoogolx avatar Mar 21 '24 08:03 igoogolx

For the rules:

Can we simplify the rules? I suggest:

  • The length of keys must be 2 or 3.
  • Only shortcuts that start with Ctrl or Cmd, Alt or Option, or Shift are valid. @GeoffreyChen777

At least we need Space for preview, enter for open, Backspace for delete.

GeoffreyChen777 avatar Mar 21 '24 08:03 GeoffreyChen777

For the rules: Can we simplify the rules? I suggest:

  • The length of keys must be 2 or 3.
  • Only shortcuts that start with Ctrl or Cmd, Alt or Option, or Shift are valid. @GeoffreyChen777

At least we need Space for preview, enter for open, Backspace for delete.

I think these shortcuts should be a default and can't be changed by users.

igoogolx avatar Mar 21 '24 08:03 igoogolx

For the rules: Can we simplify the rules? I suggest:

  • The length of keys must be 2 or 3.
  • Only shortcuts that start with Ctrl or Cmd, Alt or Option, or Shift are valid. @GeoffreyChen777

At least we need Space for preview, enter for open, Backspace for delete.

I think these shortcuts should be a default and can't be changed by users.

It’s changeable in previous versions. We have to be backward compatible.

GeoffreyChen777 avatar Mar 21 '24 08:03 GeoffreyChen777

For the rules: Can we simplify the rules? I suggest:

  • The length of keys must be 2 or 3.
  • Only shortcuts that start with Ctrl or Cmd, Alt or Option, or Shift are valid. @GeoffreyChen777

At least we need Space for preview, enter for open, Backspace for delete.

I think these shortcuts should be a default and can't be changed by users.

It’s changeable in previous versions. We have to be backward compatible.

Make sense, will keep it. Here are the rules:

  • If it's a single key, only Enter, Space, Backspace, F1-12 are valid.
  • If it has 2 or 3 keys, only shortcuts that start with Ctrl or Cmd, Alt or Option, or Shift are valid.
  • Others are invalid. @GeoffreyChen777

igoogolx avatar Mar 21 '24 08:03 igoogolx

Implemented.

GeoffreyChen777 avatar Mar 24 '24 12:03 GeoffreyChen777